[jira] [Commented] (CALCITE-4094) Allow SqlUserDefinedFunction to define an optional Strong.Policy

2020-06-30 Thread Ruben Q L (Jira)


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

Ruben Q L commented on CALCITE-4094:


Good point [~danny0405]. I guess it would be better to provide this feature via 
an interface with a {{Strong.Policy getPolicy();}} method, and let users 
implement that method in their functions.

> Allow SqlUserDefinedFunction to define an optional Strong.Policy
> 
>
> Key: CALCITE-4094
> URL: https://issues.apache.org/jira/browse/CALCITE-4094
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Reporter: Ruben Q L
>Assignee: Ruben Q L
>Priority: Major
>
> {{FilterJoinRule}} performs some optimizations based on 
> {{RelOptUitl#simplifyJoin}}. Specifically, this part of the code:
> {code}
> if (joinType.generatesNullsOnRight()
>   && Strong.isNotTrue(filter, rightBitmap)) {
> joinType = joinType.cancelNullsOnRight();
> }
> {code}
> allows e.g. a LEFT join with a condition on its RHS to be transformed into an 
> INNER join, with the condition pushed on its right input.
> In order to achieve this, the utility class {{Strong}} defines a certain 
> {{Policy}} map, depending on the {{SqlKind}} of a {{RexNode}} (i.e. depending 
> on the filter condition). In case of operators such as {{EQUALS}}, 
> {{NOT_EQUALS}}, {{LESS_THAN}}, etc, it defines {{Policy.ANY}} (i.e. 
> expression is null if and only if at least one of its arguments is null). In 
> case of a left join with conditions with this policy on the right-hand-side, 
> the join gets simplified by this module because of the nullability of the 
> right columns. However, in the case of {{SqlUserDefinedFunction}} the policy 
> is the default {{Policy.AS_IS}}, which prevents the simplification from 
> happening.
> It is proposed to enrich {{SqlUserDefinedFunction}} with an optional 
> {{Strong.Policy}}, and adapt {{Strong#isNull}} so that these functions can 
> also benefit from this simplification.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-4094) Allow SqlUserDefinedFunction to define an optional Strong.Policy

2020-06-30 Thread Danny Chen (Jira)


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

Danny Chen commented on CALCITE-4094:
-

Well, it could, but i would prefer adding an interface to override instead of a 
constructor.

Actually, there are many sql functions declared as SqlKind.OTHER_FUNCTION, not 
just the SqlUserDefinedFunction, should we consider those functions too ?

> Allow SqlUserDefinedFunction to define an optional Strong.Policy
> 
>
> Key: CALCITE-4094
> URL: https://issues.apache.org/jira/browse/CALCITE-4094
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Reporter: Ruben Q L
>Assignee: Ruben Q L
>Priority: Major
>
> {{FilterJoinRule}} performs some optimizations based on 
> {{RelOptUitl#simplifyJoin}}. Specifically, this part of the code:
> {code}
> if (joinType.generatesNullsOnRight()
>   && Strong.isNotTrue(filter, rightBitmap)) {
> joinType = joinType.cancelNullsOnRight();
> }
> {code}
> allows e.g. a LEFT join with a condition on its RHS to be transformed into an 
> INNER join, with the condition pushed on its right input.
> In order to achieve this, the utility class {{Strong}} defines a certain 
> {{Policy}} map, depending on the {{SqlKind}} of a {{RexNode}} (i.e. depending 
> on the filter condition). In case of operators such as {{EQUALS}}, 
> {{NOT_EQUALS}}, {{LESS_THAN}}, etc, it defines {{Policy.ANY}} (i.e. 
> expression is null if and only if at least one of its arguments is null). In 
> case of a left join with conditions with this policy on the right-hand-side, 
> the join gets simplified by this module because of the nullability of the 
> right columns. However, in the case of {{SqlUserDefinedFunction}} the policy 
> is the default {{Policy.AS_IS}}, which prevents the simplification from 
> happening.
> It is proposed to enrich {{SqlUserDefinedFunction}} with an optional 
> {{Strong.Policy}}, and adapt {{Strong#isNull}} so that these functions can 
> also benefit from this simplification.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-4094) Allow SqlUserDefinedFunction to define an optional Strong.Policy

2020-06-30 Thread Ruben Q L (Jira)


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

Ruben Q L commented on CALCITE-4094:


[~danny0405] the idea is having always the default policy 
{{Strong.Policy.AS_IS}} (so it will remain backwards compatible, the one who 
writes the udf does not need to specify it); but add mechanism (I guess another 
constructor) so that we can specify a different policy value.

> Allow SqlUserDefinedFunction to define an optional Strong.Policy
> 
>
> Key: CALCITE-4094
> URL: https://issues.apache.org/jira/browse/CALCITE-4094
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Reporter: Ruben Q L
>Assignee: Ruben Q L
>Priority: Major
>
> {{FilterJoinRule}} performs some optimizations based on 
> {{RelOptUitl#simplifyJoin}}. Specifically, this part of the code:
> {code}
> if (joinType.generatesNullsOnRight()
>   && Strong.isNotTrue(filter, rightBitmap)) {
> joinType = joinType.cancelNullsOnRight();
> }
> {code}
> allows e.g. a LEFT join with a condition on its RHS to be transformed into an 
> INNER join, with the condition pushed on its right input.
> In order to achieve this, the utility class {{Strong}} defines a certain 
> {{Policy}} map, depending on the {{SqlKind}} of a {{RexNode}} (i.e. depending 
> on the filter condition). In case of operators such as {{EQUALS}}, 
> {{NOT_EQUALS}}, {{LESS_THAN}}, etc, it defines {{Policy.ANY}} (i.e. 
> expression is null if and only if at least one of its arguments is null). In 
> case of a left join with conditions with this policy on the right-hand-side, 
> the join gets simplified by this module because of the nullability of the 
> right columns. However, in the case of {{SqlUserDefinedFunction}} the policy 
> is the default {{Policy.AS_IS}}, which prevents the simplification from 
> happening.
> It is proposed to enrich {{SqlUserDefinedFunction}} with an optional 
> {{Strong.Policy}}, and adapt {{Strong#isNull}} so that these functions can 
> also benefit from this simplification.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CALCITE-4094) Allow SqlUserDefinedFunction to define an optional Strong.Policy

2020-06-29 Thread Danny Chen (Jira)


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

Danny Chen commented on CALCITE-4094:
-

The question is, do you want to impose the Strong policy to UDF ? The one who 
writes the function may need to have good knowledge of what a Strong policy 
means.

> Allow SqlUserDefinedFunction to define an optional Strong.Policy
> 
>
> Key: CALCITE-4094
> URL: https://issues.apache.org/jira/browse/CALCITE-4094
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Reporter: Ruben Q L
>Assignee: Ruben Q L
>Priority: Major
>
> {{FilterJoinRule}} performs some optimizations based on 
> {{RelOptUitl#simplifyJoin}}. Specifically, this part of the code:
> {code}
> if (joinType.generatesNullsOnRight()
>   && Strong.isNotTrue(filter, rightBitmap)) {
> joinType = joinType.cancelNullsOnRight();
> }
> {code}
> allows e.g. a LEFT join with a condition on its RHS to be transformed into an 
> INNER join, with the condition pushed on its right input.
> In order to achieve this, the utility class {{Strong}} defines a certain 
> {{Policy}} map, depending on the {{SqlKind}} of a {{RexNode}} (i.e. depending 
> on the filter condition). In case of operators such as {{EQUALS}}, 
> {{NOT_EQUALS}}, {{LESS_THAN}}, etc, it defines {{Policy.ANY}} (i.e. 
> expression is null if and only if at least one of its arguments is null). In 
> case of a left join with conditions with this policy on the right-hand-side, 
> the join gets simplified by this module because of the nullability of the 
> right columns. However, in the case of {{SqlUserDefinedFunction}} the policy 
> is the default {{Policy.AS_IS}}, which prevents the simplification from 
> happening.
> It is proposed to enrich {{SqlUserDefinedFunction}} with an optional 
> {{Strong.Policy}}, and adapt {{Strong#isNull}} so that these functions can 
> also benefit from this simplification.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)