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

Fix flakey test to handle TIMESTAMP and TIMESTAMP(0) correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.22.0
    • 1.23.0
    • core

    Description

      Currently, building is not stable, there are frequently flakey tests on Linux(JDK 11) related with TIMESTAMP(0) vs TIMESTAMP.

      For example,

      https://github.com/apache/calcite/runs/584340845

      https://github.com/apache/calcite/runs/576436249

      https://github.com/apache/calcite/runs/585695121

      Below is first failure test of a consecutive failure tests from the three builds:
      org.apache.calcite.test.SqlLimitsTest > testPrintLimits() (see attachment log for detail)
      The only diff is TIMESTAMP(0) vs TIMESTAMP

       

      The root cause is:

      In BasicSqlType, the value of `toString` result and instance member `digest` might be different. For TIMESTAMP without precision (precision = -1), toString returns TIMESTAMP and digest is TIMESTAMP(0), which conflicts with real TIMESTAMP(0) with 0 as precision. 

      `Interner<RelDataType> DATATYPE_CACHE = Interners.newWeakInterner()` makes sure SqlType is singleton between invocations, TIMESTAMP(0) might return SqlType - TIMESTAMP without precision literally which is wrong. Because the global cache uses weak reference, so the cache would usually invalidate after Java GC, which mitigates the impact of the hidden bug. As for the specific environment Linux JDK 11 situation, I could not give a reasonable explanation yet, but I suppose the cause is clear.

      The fix is simple, making the digest of TIMESTAMP without precision (precision = -1) as TIMESTAMP instead of TIMESTAMP(0) would solve the problem. This could expand to all TIME and TIMESTAMP related sql types.

      Attachments

        1. common_first_error.log
          11 kB
          neoremind

        Issue Links

          Activity

            People

              danny0405 Danny Chen
              neoremind neoremind
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m