mirror of
https://github.com/apache/impala.git
synced 2026-01-27 15:03:20 -05:00
This commit addresses an issue in the CastExpr class where the clone
constructor was not properly preserving compatibility settings. The
clone constructor assigned the default compatibility regardless of the
source expression, causing substitution errors for partitioned tables.
Example:
'insert into unsafe_insert_partitioned(int_col, string_col)
values("1", null), (null, "1")'
Throws:
ERROR: IllegalStateException: Failed analysis after expr substitution.
CAUSED BY: IllegalStateException: cast STRING to INT
Tests:
- new test case added to insert-unsafe.test
Change-Id: Iff64ce02539651fcb3a90db678f74467f582648f
Reviewed-on: http://gerrit.cloudera.org:8080/20385
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
229 lines
7.6 KiB
Plaintext
229 lines
7.6 KiB
Plaintext
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select 1.0 union select int_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: int_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select 1 union select int_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: int_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select int_col from unsafe_insert union select 1;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: int_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select 1 union select string_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: string_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select 1 union select 2;
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select 1;
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) values (10.0);
|
|
---- CATCH
|
|
AnalysisException: Target table '$DATABASE.unsafe_insert' is incompatible with source expressions.
|
|
Expression '10.0' (type: DECIMAL(3,1)) is not compatible with column 'string_col' (type: STRING)
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) values (100), (1000), (1000.0);
|
|
---- CATCH
|
|
AnalysisException: Target table '$DATABASE.unsafe_insert' is incompatible with source expressions.
|
|
Expression '100' (type: DECIMAL(6,1)) is not compatible with column 'string_col' (type: STRING)
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) values (cast(100 as TINYINT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) values (cast(100 as SMALLINT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) values (cast(100 as FLOAT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) values (cast(100 as DOUBLE));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) values (cast(100 as INT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) values (cast(100 as BIGINT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(varchar_col) values (cast(100 as TINYINT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(varchar_col) values (cast(100 as SMALLINT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(varchar_col) values (cast(100 as FLOAT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(varchar_col) values (cast(100 as DOUBLE));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(varchar_col) values (cast(100 as INT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(varchar_col) values (cast(100 as BIGINT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(char_col) values (cast(100 as TINYINT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(char_col) values (cast(100 as SMALLINT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(char_col) values (cast(100 as FLOAT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(char_col) values (cast(100 as DOUBLE));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(char_col) values (cast(100 as INT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(char_col) values (cast(100 as BIGINT));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(float_col) values ("100");
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(bigint_col) values ("100");
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(smallint_col) values ("100");
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(tinyint_col) values ("100");
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(int_col) values ("100");
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(double_col) values ("100");
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(float_col) values (cast("100" as VARCHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(bigint_col) values (cast("100" as VARCHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(smallint_col) values (cast("100" as VARCHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(tinyint_col) values (cast("100" as VARCHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(int_col) values (cast("100" as VARCHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(double_col) values (cast("100" as VARCHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(float_col) values (cast("100" as CHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(bigint_col) values (cast("100" as CHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(smallint_col) values (cast("100" as CHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(tinyint_col) values (cast("100" as CHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(int_col) values (cast("100" as CHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(double_col) values (cast("100" as CHAR(10)));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(char_col) values (cast("100" as STRING));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(varchar_col) values (cast("100" as STRING));
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(float_col) values ("100"), (15629);
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(bigint_col) select string_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: string_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select smallint_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: smallint_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(tinyint_col) select string_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: string_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select tinyint_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: tinyint_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select int_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: int_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(int_col) select string_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: string_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(smallint_col) select string_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: string_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(float_col) select string_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: string_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select double_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: double_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select bigint_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: bigint_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(string_col) select float_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: float_col
|
|
====
|
|
---- QUERY
|
|
INSERT INTO unsafe_insert(double_col) select string_col from unsafe_insert;
|
|
---- CATCH
|
|
AnalysisException: Unsafe implicit cast is prohibited for non-const expression: string_col
|
|
====
|
|
---- QUERY
|
|
# Mixing unsafe and regular compatibility on column level, unsafe union between 1 and "1"
|
|
# regular union between column 'string_col' and "100".
|
|
INSERT INTO unsafe_insert(int_col, string_col) select 1, string_col from unsafe_insert union select "1", "100";
|
|
====
|
|
---- QUERY
|
|
# Regression test for expression substitution on unsafe casts.
|
|
INSERT INTO unsafe_insert(int_col, string_col) select "1", "1" from unsafe_insert union select 1, "1";
|
|
====
|
|
---- QUERY
|
|
# Regression test for expression substitution on unsafe casts with partitioned tables.
|
|
INSERT INTO unsafe_insert_partitioned(int_col, string_col) values("1", null), (null, "1");
|
|
==== |