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

Insert for multi row VALUES failed when column has values of different types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: In Progress
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      Queries like:

      insert into empnullables (empno) values (10), ('20')

      Or:

      insert into empnullables (empno, deptno) values (10, '300'), (20, null)

      Fail with an exception:

      From line 2, column 1 to line 2, column 32: Values passed to VALUES operator must have compatible types
      org.apache.calcite.runtime.CalciteContextException: From line 2, column 1 to line 2, column 32: Values passed to VALUES operator must have compatible types
      ...
          at app//org.apache.calcite.sql.validate.SqlValidatorImpl.validateValues(SqlValidatorImpl.java:5370)

      In the first query, first row has column type INTEGER and second row has column type CHAR(2).
      In the second query data type of null is infered from target data type (INTEGER).
      However types of values can be coerced.
      In case of one-by-one inserts statements work as expected. For one-row inserts this check is skipped and types are coerced later in SqlValidatorImpl#validateInsert -> checkTypeAssignment.

      Attachments

        Issue Links

          Activity

            People

              alex_pl Aleksey Plekhanov
              alex_pl Aleksey Plekhanov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

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