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

Benchao Li commented on FLINK-32363:
------------------------------------

[FLIP-154|https://cwiki.apache.org/confluence/display/FLINK/FLIP-154%3A+SQL+Implicit+Type+Coercion]
 drives an effort about this, and has no activity for two years.

> calcite 1.21 supports type coercion but flink don't enable it in validate
> -------------------------------------------------------------------------
>
>                 Key: FLINK-32363
>                 URL: https://issues.apache.org/jira/browse/FLINK-32363
>             Project: Flink
>          Issue Type: Improvement
>    Affects Versions: 1.18.0
>            Reporter: jackylau
>            Priority: Major
>             Fix For: 1.18.0
>
>
> 1) calcite 1.21 supports type coercion and enabled default while flink 
> disabled
> 2) spark /mysql can run it 
> 3) although, we can make it run by select count(distinct `if`(1>5, 'x', 
> cast(null as varchar)));
> i think we should enable it or offers a config to enable it
>  
> {code:java}
> Flink SQL> select count(distinct `if`(1>5, 'x', null));
> [ERROR] Could not execute SQL statement. Reason:
> org.apache.calcite.sql.validate.SqlValidatorException: Illegal use of 
> 'NULL'{code}
> {code:java}
> // it can run in spark
> spark-sql (default)> select count(distinct `if`(1>5, 'x', null)); 
> 0
> {code}
>  
> {code:java}
> private def createSqlValidator(catalogReader: CalciteCatalogReader) = {
>   val validator = new FlinkCalciteSqlValidator(
>     operatorTable,
>     catalogReader,
>     typeFactory,
>     SqlValidator.Config.DEFAULT
>       .withIdentifierExpansion(true)
>       .withDefaultNullCollation(FlinkPlannerImpl.defaultNullCollation)
>       .withTypeCoercionEnabled(false)
>   ) // Disable implicit type coercion for now.
>   validator
> } {code}



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

Reply via email to