Dawid Wysakowicz created CALCITE-6342:
-----------------------------------------

             Summary: Use highest input precision for datetime with/without 
local time zone
                 Key: CALCITE-6342
                 URL: https://issues.apache.org/jira/browse/CALCITE-6342
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.36.0
            Reporter: Dawid Wysakowicz


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:

{code}
                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);
                }
{code}



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

Reply via email to