Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.36.0
-
None
-
None
Description
In CALCITE-5478 it was correctly improved that the precision should be taken into account when calculating leastRestrictive type of Datetime types.
Unfortunately it still does not behave well for a call like: leastRestrictive(TIMESTAMP_LTZ(0), TIMESTAMP(3). It produces TIMESTAMP_LTZ(0).
In my opinion this should produce at least TIMESTAMP(3).
I'd suggest modifying the code a little bit to:
if (type.getSqlTypeName().getFamily() == resultType.getSqlTypeName().getFamily() && type.getSqlTypeName().allowsPrec() && type.getPrecision() != resultType.getPrecision()) { final int precision = SqlTypeUtil.maxPrecision(resultType.getPrecision(), type.getPrecision()); resultType = createSqlType(type.getSqlTypeName(), precision); }