Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0-alpha-2
Description
Any attempt to derive the return data type for the unix_timestamp function results into the following assertion error.
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)
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 in the presence of sub-queries.
Attachments
Issue Links
- links to