Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6342

Use highest input precision for datetime with/without local time zone

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.36.0
    • None
    • core
    • 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);
                      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            dwysakowicz Dawid Wysakowicz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: