[ 
https://issues.apache.org/jira/browse/CALCITE-4784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17417576#comment-17417576
 ] 

Stamatis Zampetakis commented on CALCITE-4784:
----------------------------------------------

There is already an {{assert isValid(...)}} call in the constructor of the 
{{Correlate}} and in the constructors of other relational expressions so I am 
inclined to keep the new check inside {{isValid}} method mostly for keeping 
things uniform.

> 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: 20m
>  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)

Reply via email to