You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2021/09/17 15:28:00 UTC
[jira] [Commented] (CALCITE-4784) Ensure Correlate#requiredColumns
is subset of columns in left relation
[ https://issues.apache.org/jira/browse/CALCITE-4784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17416759#comment-17416759 ]
Julian Hyde commented on CALCITE-4784:
--------------------------------------
If it’s a quick check, consider making it a precondition in the constructor. Invariants are good.
> Ensure Correlate#requiredColumns is subset of columns in left relation
> ----------------------------------------------------------------------
>
> Key: CALCITE-4784
> URL: https://issues.apache.org/jira/browse/CALCITE-4784
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Stamatis Zampetakis
> Assignee: Stamatis Zampetakis
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.28.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The {{Correlate}} [expression|https://github.com/apache/calcite/blob/f3baf348598fcc6bc4f97a0abee3f99309e5bf76/core/src/main/java/org/apache/calcite/rel/core/Correlate.java] has among others a field ({{requiredColumns}} for representing the set of columns that are used by the correlation.
> {code:java}
> public abstract class Correlate extends BiRel {
> protected final CorrelationId correlationId;
> protected final ImmutableBitSet requiredColumns;
> protected final JoinRelType joinType;
> /**
> * Returns the required columns in left relation required for the correlation
> * in the right.
> *
> * @return columns in left relation required for the correlation in the right
> */
> public ImmutableBitSet getRequiredColumns() {
> return requiredColumns;
> }
> {code}
> As the javadoc indicates (implicitly) these columns must be a subset of the columns of the left relation. This is currently not enforced when creating a correlation which can lead to invalid plans and runtime failures which are hard to investigate.
> I propose to introduce an additional check inside {{Correlate#isValid}} method for enforcing that required columns are valid.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)