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

Incomplete implicit type conversion for insert values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • core

    Description

      • Target table schema
            // Register "T1" table.
            final MockTable t1 =
                MockTable.create(this, tSchema, "T1", false, 7.0, null);
            t1.addColumn("t1_varchar20", f.varchar20Type, true);
            t1.addColumn("t1_smallint", f.smallintType);
            t1.addColumn("t1_int", f.intType);
            t1.addColumn("t1_bigint", f.bigintType);
            t1.addColumn("t1_float", f.floatType);
            t1.addColumn("t1_double", f.doubleType);
            t1.addColumn("t1_decimal", f.decimalType);
            t1.addColumn("t1_timestamp", f.timestampType);
            t1.addColumn("t1_date", f.dateType);
            t1.addColumn("t1_binary", f.binaryType);
            t1.addColumn("t1_boolean", f.booleanType);
            registerTable(t1);
        
      • Insert query
        insert into t1 values 
        ('a', 1, 1.0, 0, 0, 0, 0, TIMESTAMP '2021-11-28 00:00:00', date '2021-11-28', x'0A', false), 
        ('b', 2,  2, 0, 0, 0, 0, TIMESTAMP '2021-11-28 00:00:00', date '2021-11-28', x'0A', false), 
        ('c', CAST(3 AS SMALLINT),  3.0, 0, 0, 0, 0, TIMESTAMP '2021-11-28 00:00:00', date '2021-11-28', x'0A', false), 
        ('d', 4, 4.0, 0, 0, 0, 0, TIMESTAMP '2021-11-28 00:00:00', date '2021-11-28', x'0A', false), 
        ('e', 5, 5.0, 0, 0, 0, 0, TIMESTAMP '2021-11-28 00:00:00', date '2021-11-28', x'0A', false)
        
      • Incorrect converted plan: the data type is not matched with table schema
        LogicalTableModify(table=[[CATALOG, SALES, T1]], operation=[INSERT], flattened=[false])
          LogicalValues(tuples=[[
          { 'a', 1, 1, 0, 0, 0, 0, 2021-11-28 00:00:00, 2021-11-28, X'0a', false },
          { 'b', 2, 2, 0, 0, 0, 0, 2021-11-28 00:00:00, 2021-11-28, X'0a', false },
          { 'c', 3, ^3.0^, 0, 0, 0, 0, 2021-11-28 00:00:00, 2021-11-28, X'0a', false },
          { 'd', 4, ^4.0^, 0, 0, 0, 0, 2021-11-28 00:00:00, 2021-11-28, X'0a', false },
          { 'e', 5, ^5.0^, 0, 0, 0, 0, 2021-11-28 00:00:00, 2021-11-28, X'0a', false }]])
                    // Here are some numbers that are not integers
      • Correct converted plan
      LogicalTableModify(table=[[CATALOG, SALES, T1]], operation=[INSERT], flattened=[false])
        LogicalValues(tuples=[[
      { 'a', 1, 1, 0, 0, 0, 0, 2021-11-28 00:00:00, 2021-11-28, X'0a', false },
       { 'b', 2, 2, 0, 0, 0, 0, 2021-11-28 00:00:00, 2021-11-28, X'0a', false },
       { 'c', 3, 3, 0, 0, 0, 0, 2021-11-28 00:00:00, 2021-11-28, X'0a', false },
       { 'd', 4, 4, 0, 0, 0, 0, 2021-11-28 00:00:00, 2021-11-28, X'0a', false }, 
      { 'e', 5, 5, 0, 0, 0, 0, 2021-11-28 00:00:00, 2021-11-28, X'0a', false }]])
      
      

      Attachments

        Issue Links

          Activity

            People

              jiajunbernoulli Jiajun Xie
              jiajunbernoulli Jiajun Xie
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

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