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

JDBC adapter generates invalid casts on PostgreSQL, because PostgreSQL does not have TINYINT and DOUBLE types

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.16.0
    • Fix Version/s: 1.17.0
    • Component/s: jdbc-adapter
    • Labels:
      None

      Description

      The types `TINYINT` and `DOUBLE` do not exist in Postgres, so attempting to cast to them throws a runtime exception, e.g.

       

      // query
      select CAST("store_id" as TINYINT) from "foodmart"."expense_fact"
      
      // exception
      java.lang.RuntimeException: exception while executing [select CAST("store_id" as TINYINT) from "foodmart"."expense_fact"]
      at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
      Caused by: java.lang.RuntimeException: With materializationsEnabled=false, limit=0
      at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
      Caused by: java.sql.SQLException: 
      Error while executing SQL "select CAST("store_id" as TINYINT) from "foodmart"."expense_fact"": while executing SQL [SELECT CAST("store_id" AS TINYINT)
      FROM "public"."expense_fact"]
      at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
      Caused by: java.lang.RuntimeException: 
      while executing SQL [SELECT CAST("store_id" AS TINYINT)
      FROM "public"."expense_fact"]
      at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
      Caused by: org.postgresql.util.PSQLException: 
      ERROR: type "tinyint" does not exist
      Position: 27
      at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
      

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                chris-baynes Chris Baynes
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: