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

Julian Hyde commented on CALCITE-6413:
--------------------------------------

One small quibble. I believe the coercion logic is invoked by the 
sql-to-rel-converter, not the validator.

The fix should include two tests:
 * One where the conversion is not valid (i.e. the types are not comparable); 
the validator test should check that an error is thrown.
 * One where the conversion is valid but the coercion generates non-trivial 
code; a sql-to-rel-converter test should check that two equivalent queries 
written using ON and USING generate identical plans.

> SqlValidator does not invoke  TypeCoercionImpl::binaryComparisonCoercion for 
> both NATURAL and USING join conditions
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6413
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6413
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Maksim Zhuravkov
>            Priority: Minor
>
> This can be observed by adding these test cases to `SqlToRelConverterTest`:
> 1. Join condition ON expression
> {code:java}
>  @Test void test1() {
>     final String sql = "select * from emp JOIN (VALUES ('XXX')) t(deptno)  ON 
> emp.deptno = t.deptno";
>     sql(sql).ok();
>   }
> {code}
> 2. Common columns (USING/NATURAL) (since they both share the same code path 
> for building join condition)
> {code:java}
>   @Test void test2() {
>     final String sql = "select * from emp JOIN (VALUES ('XXX')) t(deptno)  
> USING (deptno)";
>     sql(sql).ok();
>   }
> {code}
> When test 1 runs, the SqlValidator calls 
> TypeCoercionImpl::binaryComparisonCoercion
> When test 2 runs, the SqlValidator does not call 
> TypeCoercionImpl::binaryComparisonCoercion.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to