Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
HIVE-2249 introduced some specialized type inference logic that kicks in when there are comparisons between columns and numeric constant expressions.
Consider for instance a comparison between a BIGINT column and a STRING constant.
SELECT * FROM table WHERE c_bigint = '9223372036854775807'
The type derivation logic will attempt to convert the STRING constant to BIGINT and evaluate the expression by comparing long values.
Currently (commit 5cbffb532a586226500abc498d6505722d62234d), the query above throws the following ERROR/WARNING:
Comparing bigint and string may result in loss of information.
This is due to strict type checking (controlled via hive.strict.checks.type.safety property) that is now applied before the constant type inference logic described above.
In this case, the ERROR/WARNING is a bit misleading since there is no real risk for losing precision/information since the STRING constant fits into a BIGINT (Java long) and the whole comparison can be evaluated without precision loss.
For quite some time, strict type checking was performed after constant type inference (and not before) but the behavior was changed unintentionally by HIVE-23100.
The goal of this change is to perform constant type inference before strict type validation (behavior before HIVE-23100) to restore backward compatibility and remove some unnecessary warnings/errors during compilation.
Attachments
Issue Links
- relates to
-
HIVE-2249 When creating constant expression for numbers, try to infer type from another comparison operand, instead of trying to use integer first, and then long and double
- Closed
-
HIVE-23100 Create RexNode factory and use it in CalcitePlanner
- Closed
- links to