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

RelToSqlConverter fails on literal, untyped nulls

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • 1.25.0
    • None

    Description

      RelToSqlConverter fails on literal, untyped nulls. Here is a simple test in RelToSqlConverterTest:
       

      @Test void testUntypedNull() {
       final String sql = "SELECT NULL FROM \"warehouse_class\"";
       final String expected = "SELECT NULL FROM \"warehouse_class\"";
       sql(sql).ok(expected);
      }

      The expected SQL is probably not exactly the right expected SQL, but the test explodes on 1.24 so it doesn't matter for our purposes. Here is the top of the stack trace (on current master ad53962f) :

      Unsupported type when convertTypeToSpec: NULLUnsupported type when convertTypeToSpec: NULL
      java.lang.UnsupportedOperationException: Unsupported type when convertTypeToSpec: NULL at org.apache.calcite.sql.type.SqlTypeUtil.convertTypeToSpec(SqlTypeUtil.java:1027)
      at org.apache.calcite.sql.SqlDialect.getCastSpec(SqlDialect.java:778)
      at org.apache.calcite.rel.rel2sql.RelToSqlConverter.castNullType(RelToSqlConverter.java:361)

       
      Seems to be an unintended side-effect of the fix for CALCITE-4066, 8db7c9d6.

      Attachments

        Issue Links

          Activity

            People

              julianhyde Julian Hyde
              swtalbot Steven Talbot
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 40m
                  40m