Uploaded image for project: 'CarbonData'
  1. CarbonData
  2. CARBONDATA-3652

No exception is thrown when the number of insert and select table columns is inconsistent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.0.0
    • spark-integration
    • None

    Description

      In production, we run a sql 'insert into table1 select * from table2' every day,(table1 is a carbon table), but when some one alter table2 add a column, the above sql won't throw exception, and make the data in table1 error. But if table1 is a parquet table, it will throw exception:

      `default`.`table1` requires that the data to be inserted have the same number of columns as the target table: target table has 3 column(s) but the inserted data has 4 column(s), including 0 partition column(s) having constant value(s).;
      

      It should also throw exception when the number of insert and select table columns is inconsistent.

      Here is the test code, it make the data in table1 error. I will add a pr to fix it.

          sql("create table table1 (col1 string, col2 string) partitioned by(pt string) stored by 'carbondata'")
          sql("create table table2 (t2_c1 string, t2_c2 string, t2_c3 string) partitioned by(pt string)")
      
          sql("insert overwrite table table2 partition(pt=20200101) values('v11', 'v12', 'v13')")
          sql("insert into table1 select * from table2")
          checkAnswer(sql("select * from table1"), Row("v11", "v12", "v13"))
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              shenhong shenh062326
              Votes:
              0 Vote for this issue
              Watchers:
              2 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 - 3h 10m
                  3h 10m