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

Hongrong Cao commented on KYLIN-5717:
-------------------------------------

h2. Root Cause


ToDateUDF This class only supports 'yyyy-MM-dd' 'yyyy-MM' 'yyyy' and 'y' 
implementations. For implementations that do not, a null is returned by default.

When calcite optimizes this Project calculation using the volcano planner, the 
method org.apache.calcite.rex.RexExecutable#reduce collapses project 
expressions that are constants, and the udf above returns null, which results 
in incorrectly collapsed values. This method collapses a constant project 
expression, which results in the wrong value being collapsed due to the default 
return of null in udf above.
h2. Dev Design


For this unsupported case, it is sufficient to throw an exception by default, 
and calcite will catch the exception and disable the folding, and the operator 
will be generated without problems. After that, the project is supported when 
converting to spark arithmetic, and the query works fine.

> The to_date function is not aligned with SparkSQL. When converting to a time 
> format such as yyyyMMdd, the result of the query hitting the snapshot is 
> incorrect
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: KYLIN-5717
>                 URL: https://issues.apache.org/jira/browse/KYLIN-5717
>             Project: Kylin
>          Issue Type: Bug
>    Affects Versions: 5.0-beta
>            Reporter: Hongrong Cao
>            Assignee: pengfei.zhan
>            Priority: Major
>             Fix For: 5.0.0
>
>
> The to_date function is not aligned with SparkSQL.
> When converting to a time format such as yyyyMMdd, the result of the query 
> hitting the snapshot is incorrect;



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

Reply via email to