Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-20649

SQL: class cast exception in EXCEPT SELECT with different column types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0
    • sql

    Description

      Steps to reproduce:

      1. Create two tables, one with `INT` column and one with `NUMERIC`. Add some sample data into both.

      -- first table
      drop table if exists tmp_table_age_name_wage;
      create table tmp_table_age_name_wage (key_field INT PRIMARY KEY,AGE INT,field1 VARCHAR,field2 INT);
      insert into tmp_table_age_name_wage (key_field,AGE,field1,field2) values (1, 42,'John',100000);
      insert into tmp_table_age_name_wage (key_field,AGE,field1,field2) values (2, 43,'Jack',50000);
      -- second table
      drop table if exists tmp_table_age_name_wage_2;
      create table tmp_table_age_name_wage_2 (key_field INT PRIMARY KEY,AGE DECIMAL,field1 VARCHAR,field2 DECIMAL);
      insert into tmp_table_age_name_wage_2 (key_field,AGE,field1,field2) values (1, 42,'John',100000);
      

      2. `UNION SELECT` for columns with different types works fine:

      sql-cli> SELECT AGE,field1,field2 FROM tmp_table_age_name_wage UNION SELECT AGE,field1,field2 FROM tmp_table_age_name_wage_2;
      ╔═════╤════════╤════════╗
      ║ AGE │ FIELD1 │ FIELD2 ║
      ╠═════╪════════╪════════╣
      ║ 42  │ John   │ 100000 ║
      ╟─────┼────────┼────────╢
      ║ 42  │ John   │ 100000 ║
      ╟─────┼────────┼────────╢
      ║ 43  │ Jack   │ 50000  ║
      ╚═════╧════════╧════════╝
      

      3. Nevertheless, `EXCEPT SELECT` leads to class casting exception:

      sql-cli> SELECT AGE,field1,field2 FROM tmp_table_age_name_wage EXCEPT SELECT AGE,field1,field2 FROM tmp_table_age_name_wage_2;
      SQL query execution error
      class java.math.BigDecimal cannot be cast to class java.lang.Integer (java.math.BigDecimal and java.lang.Integer are in module java.base of loader 'bootstrap')
      

      The query above worked in AI3 some time ago (e.g., in 3.0.0-beta1), but not now. Looks like a degradation.

      Attachments

        Issue Links

          Activity

            People

              xtern Pavel Pereslegin
              akhitrin Andrey Khitrin
              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 - 20m
                  20m