[ 
https://issues.apache.org/jira/browse/HIVE-27157?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stamatis Zampetakis resolved HIVE-27157.
----------------------------------------
    Fix Version/s: 4.0.0
       Resolution: Fixed

Fixed in 
https://github.com/apache/hive/commit/b30fe4c1af9d134e7e533a715f2401a67530d016. 
Thanks for the review [~kkasa]!

> AssertionError when inferring return type for unix_timestamp function
> ---------------------------------------------------------------------
>
>                 Key: HIVE-27157
>                 URL: https://issues.apache.org/jira/browse/HIVE-27157
>             Project: Hive
>          Issue Type: Bug
>          Components: CBO
>    Affects Versions: 4.0.0-alpha-2
>            Reporter: Stamatis Zampetakis
>            Assignee: Stamatis Zampetakis
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.0.0
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Any attempt to derive the return data type for the {{unix_timestamp}} 
> function results into the following assertion error.
> {noformat}
> java.lang.AssertionError: typeName.allowsPrecScale(true, false): BIGINT
>       at 
> org.apache.calcite.sql.type.BasicSqlType.checkPrecScale(BasicSqlType.java:65)
>       at org.apache.calcite.sql.type.BasicSqlType.<init>(BasicSqlType.java:81)
>       at 
> org.apache.calcite.sql.type.SqlTypeFactoryImpl.createSqlType(SqlTypeFactoryImpl.java:67)
>       at 
> org.apache.calcite.sql.fun.SqlAbstractTimeFunction.inferReturnType(SqlAbstractTimeFunction.java:78)
>       at 
> org.apache.calcite.rex.RexBuilder.deriveReturnType(RexBuilder.java:278)
> {noformat}
> due to a faulty implementation of type inference for the respective operators:
>  * 
> [https://github.com/apache/hive/blob/52360151dc43904217e812efde1069d6225e9570/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveUnixTimestampSqlOperator.java]
>  * 
> [https://github.com/apache/hive/blob/52360151dc43904217e812efde1069d6225e9570/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveToUnixTimestampSqlOperator.java]
> Although at this stage in master it is not possible to reproduce the problem 
> with an actual SQL query the buggy implementation must be fixed since slight 
> changes in the code/CBO rules may lead to methods relying on 
> {{{}SqlOperator.inferReturnType{}}}.
> Note that in older versions of Hive it is possible to hit the AssertionError 
> in various ways. For example in Hive 3.1.3 (and older), the error may come 
> from 
> [HiveRelDecorrelator|https://github.com/apache/hive/blob/4df4d75bf1e16fe0af75aad0b4179c34c07fc975/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelDecorrelator.java#L1933]
>  in the presence of sub-queries.



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

Reply via email to