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

RelToSqlConverter does not support null without a cast: "Unsupported type when convertTypeToSpec: NULL"

    XMLWordPrintableJSON

Details

    Description

      RelToSqlConverterTest:

       @Test void testSelectNullNoCast() {
        String query = "select \"product_id\", null as dummy from \"product\"";
        final String expected = "SELECT \"product_id\", CAST(NULL AS NULL) AS \"DUMMY\"\n"
            + "FROM \"foodmart\".\"product\"";
        sql(query).ok(expected);
      }

      the test works fine in 1.23.

      result in 1.24:

      Unsupported type when convertTypeToSpec: NULL
      java.lang.UnsupportedOperationException: Unsupported type when convertTypeToSpec: NULL at org.apache.calcite.sql.type.SqlTypeUtil.convertTypeToSpec(SqlTypeUtil.java:1078) at org.apache.calcite.sql.SqlDialect.getCastSpec(SqlDialect.java:790) at org.apache.calcite.rel.rel2sql.RelToSqlConverter.castNullType(RelToSqlConverter.java:361) at org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:342) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:524) at org.apache.calcite.rel.rel2sql.RelToSqlConverter.dispatch(RelToSqlConverter.java:131)

      Please note, that there is an existing test "testSelectNull()", but it tests nulls with a cast, "CAST(NULL AS INT)".

      Attachments

        Issue Links

          Activity

            People

              anha Anton Haidai
              anha Anton Haidai
              Votes:
              0 Vote for this issue
              Watchers:
              5 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 40m
                  1h 40m