You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2018/04/28 05:28:45 UTC

[2/4] impala git commit: IMPALA-6340, IMPALA-6518: Check that decimal types are compatible in FE

http://git-wip-us.apache.org/repos/asf/impala/blob/d0f838b6/testdata/workloads/functional-planner/queries/PlannerTest/complex-types-file-formats.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/functional-planner/queries/PlannerTest/complex-types-file-formats.test b/testdata/workloads/functional-planner/queries/PlannerTest/complex-types-file-formats.test
index 1e61b7d..b902f26 100644
--- a/testdata/workloads/functional-planner/queries/PlannerTest/complex-types-file-formats.test
+++ b/testdata/workloads/functional-planner/queries/PlannerTest/complex-types-file-formats.test
@@ -18,12 +18,12 @@ PLAN-ROOT SINK
 # Complex types are not supported on ORC.
 select 1 from functional_orc_def.complextypes_fileformat t, t.a
 ---- PLAN
-not implemented: Scan of table 't' in format 'ORC' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of table 't' in format 'ORC' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 select s.f1 from functional_orc_def.complextypes_fileformat t, t.m
 ---- PLAN
-not implemented: Scan of table 't' in format 'ORC' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of table 't' in format 'ORC' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Complex types are not supported on ORC, however queries materializing
@@ -50,31 +50,31 @@ PLAN-ROOT SINK
 # Complex types are not supported on Avro.
 select s.f1 from functional_avro_snap.complextypes_fileformat t, t.a
 ---- PLAN
-not implemented: Scan of table 't' in format 'AVRO' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of table 't' in format 'AVRO' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Complex types are not supported on text files.
 select s.f1 from functional.complextypes_fileformat t, t.a
 ---- PLAN
-not implemented: Scan of table 't' in format 'TEXT' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of table 't' in format 'TEXT' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Complex types are not supported on text files, even if no complex-typed
 # columns are selected.
 select 1 from functional.complextypes_fileformat
 ---- PLAN
-not implemented: Scan of table 'functional.complextypes_fileformat' in format 'TEXT' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of table 'functional.complextypes_fileformat' in format 'TEXT' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Complex types are not supported on RC files.
 select 1 from functional_rc_snap.complextypes_fileformat t, t.a
 ---- PLAN
-not implemented: Scan of table 't' in format 'RC_FILE' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of table 't' in format 'RC_FILE' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 select s.f1 from functional_rc_snap.complextypes_fileformat t, t.m
 ---- PLAN
-not implemented: Scan of table 't' in format 'RC_FILE' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of table 't' in format 'RC_FILE' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Complex types are not supported on RC files, however queries materializing
@@ -101,7 +101,7 @@ PLAN-ROOT SINK
 # Complex types are not supported on sequence files.
 select s.f1 from functional_seq_snap.complextypes_fileformat t, t.a
 ---- PLAN
-not implemented: Scan of table 't' in format 'SEQUENCE_FILE' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of table 't' in format 'SEQUENCE_FILE' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Queries referencing only scalar typed columns on sequence files
@@ -119,7 +119,7 @@ PLAN-ROOT SINK
 # can be seen in tests below.
 select s.f1 from functional.complextypes_multifileformat t, t.a
 ---- PLAN
-not implemented: Scan of partition
+NotImplementedException: Scan of partition
 ====
 # Scanning an HBase table with complex-types columns is ok as long as no complex-typed
 # columns are selected.
@@ -133,14 +133,14 @@ PLAN-ROOT SINK
 # column is selected.
 select id from functional_hbase.allcomplextypes t, t.int_array_col
 ---- PLAN
-not implemented: Scan of table 't.int_array_col' is not supported because 't' references a nested field/collection.
+NotImplementedException: Scan of table 't.int_array_col' is not supported because 't' references a nested field/collection.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Scanning an HBase table with complex-types columns fails if a complex-typed
 # column is selected.
 select complex_struct_col.f1 from functional_hbase.allcomplextypes
 ---- PLAN
-not implemented: Scan of table 'functional_hbase.allcomplextypes.complex_struct_col.f1' is not supported because 'functional_hbase.allcomplextypes' references a nested field/collection.
+NotImplementedException: Scan of table 'functional_hbase.allcomplextypes.complex_struct_col.f1' is not supported because 'functional_hbase.allcomplextypes' references a nested field/collection.
 Complex types are supported for these file formats: PARQUET.
 ====
 # The complextypes_multifileformat has five partitions with different file formats:
@@ -152,7 +152,7 @@ Complex types are supported for these file formats: PARQUET.
 # Scanning a text partition of a multi-format table with complex types fails.
 select 1 from functional.complextypes_multifileformat where p = 1
 ---- PLAN
-not implemented: Scan of partition 'p=1' in format 'TEXT' of table 'functional.complextypes_multifileformat' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of partition 'p=1' in format 'TEXT' of table 'functional.complextypes_multifileformat' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Scanning a Parquet partition of a multi-format table with complex types plans ok.
@@ -175,13 +175,13 @@ PLAN-ROOT SINK
 # Scanning an Avro partition of a multi-format table with complex types fails.
 select s.f1 from functional.complextypes_multifileformat t, t.a where p = 3
 ---- PLAN
-not implemented: Scan of partition 'p=3' in format 'AVRO' of table 't' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of partition 'p=3' in format 'AVRO' of table 't' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Scanning an RC file partition of a multi-format table with complex types fails.
 select id from functional.complextypes_multifileformat t, t.a where p = 4
 ---- PLAN
-not implemented: Scan of partition 'p=4' in format 'RC_FILE' of table 't' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of partition 'p=4' in format 'RC_FILE' of table 't' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Complex types are not supported on RC files but count(*) and similar
@@ -199,7 +199,7 @@ PLAN-ROOT SINK
 # Scanning an ORC file partition of a multi-format table with complex types fails.
 select id from functional.complextypes_multifileformat t, t.a where p = 5
 ---- PLAN
-not implemented: Scan of partition 'p=5' in format 'ORC' of table 't' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
+NotImplementedException: Scan of partition 'p=5' in format 'ORC' of table 't' is not supported because the table has a column 's' with a complex type 'STRUCT<f1:STRING,f2:INT>'.
 Complex types are supported for these file formats: PARQUET.
 ====
 # Complex types are not supported on ORC files but count(*) and similar

http://git-wip-us.apache.org/repos/asf/impala/blob/d0f838b6/testdata/workloads/functional-planner/queries/PlannerTest/joins.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/functional-planner/queries/PlannerTest/joins.test b/testdata/workloads/functional-planner/queries/PlannerTest/joins.test
index c85a5d1..26d4d2f 100644
--- a/testdata/workloads/functional-planner/queries/PlannerTest/joins.test
+++ b/testdata/workloads/functional-planner/queries/PlannerTest/joins.test
@@ -2520,3 +2520,49 @@ PLAN-ROOT SINK
 00:SCAN HDFS [tpch.customer a]
    partitions=1/1 files=1 size=23.08MB
 ====
+with
+  t1 as (select cast(0 as decimal(20, 0)) as c1),
+  t2 as (select cast(0 as decimal(19, 19)) as c2)
+select * from t1 join t2 on (c1 = c2)
+---- QUERYOPTIONS
+decimal_v2=false
+---- PLAN
+PLAN-ROOT SINK
+|
+02:HASH JOIN [INNER JOIN]
+|  hash predicates: c1 = c2
+|
+|--01:UNION
+|     constant-operands=1
+|
+00:UNION
+   constant-operands=1
+====
+# Cannot create a hash join because decimal types are incompatible due to decimal_v2.
+with
+  t1 as (select cast(0 as decimal(20, 0)) as c1),
+  t2 as (select cast(0 as decimal(19, 19)) as c2)
+select * from t1 join t2 on (c1 = c2)
+---- QUERYOPTIONS
+decimal_v2=true
+---- PLAN
+InternalException: Unable create a hash join with equi-join predicate c1 = c2 because the operands cannot be cast without loss of precision. Operand types: DECIMAL(20,0) = DECIMAL(19,19).
+====
+with
+  t1 as (select cast(0 as decimal(19, 0)) as c1),
+  t2 as (select cast(0 as decimal(19, 19)) as c2)
+select * from t1 join t2 on (c1 = c2)
+---- QUERYOPTIONS
+decimal_v2=true
+---- PLAN
+PLAN-ROOT SINK
+|
+02:HASH JOIN [INNER JOIN]
+|  hash predicates: c1 = c2
+|
+|--01:UNION
+|     constant-operands=1
+|
+00:UNION
+   constant-operands=1
+====

http://git-wip-us.apache.org/repos/asf/impala/blob/d0f838b6/testdata/workloads/functional-planner/queries/PlannerTest/mt-dop-validation.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/functional-planner/queries/PlannerTest/mt-dop-validation.test b/testdata/workloads/functional-planner/queries/PlannerTest/mt-dop-validation.test
index 61d646b..0bcb1a9 100644
--- a/testdata/workloads/functional-planner/queries/PlannerTest/mt-dop-validation.test
+++ b/testdata/workloads/functional-planner/queries/PlannerTest/mt-dop-validation.test
@@ -3,9 +3,9 @@ select count(*) from
 functional_parquet.alltypestiny a,
 functional_parquet.alltypestiny b
 ---- PLAN
-not implemented: MT_DOP not supported for plans with base table joins or table sinks.
+NotImplementedException: MT_DOP not supported for plans with base table joins or table sinks.
 ---- PARALLELPLANS
-not implemented: MT_DOP not supported for plans with base table joins or table sinks.
+NotImplementedException: MT_DOP not supported for plans with base table joins or table sinks.
 ====
 # Distributed hash-join not allowed.
 select count(*) from
@@ -13,24 +13,24 @@ functional_parquet.alltypestiny a,
 functional_parquet.alltypestiny b
 where a.id = b.id
 ---- PLAN
-not implemented: MT_DOP not supported for plans with base table joins or table sinks.
+NotImplementedException: MT_DOP not supported for plans with base table joins or table sinks.
 ---- PARALLELPLANS
-not implemented: MT_DOP not supported for plans with base table joins or table sinks.
+NotImplementedException: MT_DOP not supported for plans with base table joins or table sinks.
 ====
 # Insert not allowed.
 insert into functional_parquet.alltypes partition(year,month)
 select * from functional_parquet.alltypessmall
 ---- PLAN
-not implemented: MT_DOP not supported for plans with base table joins or table sinks.
+NotImplementedException: MT_DOP not supported for plans with base table joins or table sinks.
 ---- PARALLELPLANS
-not implemented: MT_DOP not supported for plans with base table joins or table sinks.
+NotImplementedException: MT_DOP not supported for plans with base table joins or table sinks.
 ====
 # CTAS not allowed.
 create table ctas_mt_dop_test as select * from functional_parquet.alltypes
 ---- PLAN
-not implemented: MT_DOP not supported for plans with base table joins or table sinks.
+NotImplementedException: MT_DOP not supported for plans with base table joins or table sinks.
 ---- PARALLELPLANS
-not implemented: MT_DOP not supported for plans with base table joins or table sinks.
+NotImplementedException: MT_DOP not supported for plans with base table joins or table sinks.
 ====
 # Single-table scan/filter/agg/topn should work.
 select count(int_col) cnt from functional_parquet.alltypes

http://git-wip-us.apache.org/repos/asf/impala/blob/d0f838b6/testdata/workloads/functional-planner/queries/PlannerTest/nested-loop-join.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/functional-planner/queries/PlannerTest/nested-loop-join.test b/testdata/workloads/functional-planner/queries/PlannerTest/nested-loop-join.test
index af3d101..2b23443 100644
--- a/testdata/workloads/functional-planner/queries/PlannerTest/nested-loop-join.test
+++ b/testdata/workloads/functional-planner/queries/PlannerTest/nested-loop-join.test
@@ -26,7 +26,7 @@ PLAN-ROOT SINK
    partitions=4/4 files=4 size=460B
    predicates: a.id < 10
 ---- DISTRIBUTEDPLAN
-not implemented: Error generating a valid execution plan for this query. A RIGHT OUTER JOIN type with no equi-join predicates can only be executed with a single node plan.
+NotImplementedException: Error generating a valid execution plan for this query. A RIGHT OUTER JOIN type with no equi-join predicates can only be executed with a single node plan.
 ====
 # Right semi joins with non-equi join predicates
 select straight_join *
@@ -54,7 +54,7 @@ PLAN-ROOT SINK
 00:SCAN HDFS [functional.alltypestiny a]
    partitions=4/4 files=4 size=460B
 ---- DISTRIBUTEDPLAN
-not implemented: Error generating a valid execution plan for this query. A RIGHT SEMI JOIN type with no equi-join predicates can only be executed with a single node plan.
+NotImplementedException: Error generating a valid execution plan for this query. A RIGHT SEMI JOIN type with no equi-join predicates can only be executed with a single node plan.
 ====
 # Full outer joins with non-equi join predicates
 select straight_join *
@@ -91,7 +91,7 @@ PLAN-ROOT SINK
    partitions=4/4 files=4 size=460B
    predicates: a.id < 10
 ---- DISTRIBUTEDPLAN
-not implemented: Error generating a valid execution plan for this query. A FULL OUTER JOIN type with no equi-join predicates can only be executed with a single node plan.
+NotImplementedException: Error generating a valid execution plan for this query. A FULL OUTER JOIN type with no equi-join predicates can only be executed with a single node plan.
 ====
 # Right anti join with non-equi join predicates
 select straight_join count(*)
@@ -114,7 +114,7 @@ PLAN-ROOT SINK
 00:SCAN HDFS [functional.alltypestiny a]
    partitions=4/4 files=4 size=460B
 ---- DISTRIBUTEDPLAN
-not implemented: Error generating a valid execution plan for this query. A RIGHT ANTI JOIN type with no equi-join predicates can only be executed with a single node plan.
+NotImplementedException: Error generating a valid execution plan for this query. A RIGHT ANTI JOIN type with no equi-join predicates can only be executed with a single node plan.
 ====
 # Inner and right joins with non-equi join predicates
 select straight_join count(*)
@@ -157,7 +157,7 @@ PLAN-ROOT SINK
 00:SCAN HDFS [functional.alltypestiny a]
    partitions=4/4 files=4 size=460B
 ---- DISTRIBUTEDPLAN
-not implemented: Error generating a valid execution plan for this query. A RIGHT ANTI JOIN type with no equi-join predicates can only be executed with a single node plan.
+NotImplementedException: Error generating a valid execution plan for this query. A RIGHT ANTI JOIN type with no equi-join predicates can only be executed with a single node plan.
 ====
 # Right semi and outer joins are inverted to make them executable.
 # Same query as above but without the straight join hint.

http://git-wip-us.apache.org/repos/asf/impala/blob/d0f838b6/testdata/workloads/functional-query/queries/QueryTest/decimal-exprs.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/functional-query/queries/QueryTest/decimal-exprs.test b/testdata/workloads/functional-query/queries/QueryTest/decimal-exprs.test
index 7c98819..a4bfb83 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/decimal-exprs.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/decimal-exprs.test
@@ -128,12 +128,6 @@ DECIMAL
 UDF WARNING: Decimal expression overflowed, returning NULL
 ====
 ---- QUERY
-set decimal_v2=true;
-select coalesce(1.8, cast(0 as decimal(38,38)));
----- CATCH
-UDF ERROR: Decimal expression overflowed
-====
----- QUERY
 # DECIMAL v1 sum() overflow. A negative number is incorrectly returned due to overflow.
 set decimal_v2=false;
 select sum(d6 * cast(4e37 as decimal(38,0))) from decimal_tbl;
@@ -321,6 +315,37 @@ group by l_tax having avg(l_extendedprice) > 38247.190 order by 1;
 DECIMAL
 ====
 ---- QUERY
+# Test AVG overflow due to DECIMAL_v2
+set decimal_v2=false;
+select avg(c) from (select cast(1e32 as decimal(38,0)) - cast(1 as decimal(38,0)) as c) t
+---- RESULTS
+99999999999999999999999999999999
+---- TYPES
+DECIMAL
+====
+---- QUERY
+set decimal_v2=false;
+select avg(c) from (select cast(1e32 as decimal(38,0)) as c) t;
+---- RESULTS
+100000000000000000000000000000000
+---- TYPES
+DECIMAL
+====
+---- QUERY
+set decimal_v2=true;
+select avg(c) from (select cast(1e32 as decimal(38,0)) - cast(1 as decimal(38,0)) as c) t
+---- RESULTS
+99999999999999999999999999999999.000000
+---- TYPES
+DECIMAL
+====
+---- QUERY
+set decimal_v2=true;
+select avg(c) from (select cast(1e32 as decimal(38,0)) as c) t;
+---- CATCH
+UDF ERROR: Avg computation overflowed
+====
+---- QUERY
 # Test sum() and avg() analytic fns with start bounds (tests Remove() for decimal)
 # with DECIMAL_V1
 set decimal_v2=false;

http://git-wip-us.apache.org/repos/asf/impala/blob/d0f838b6/testdata/workloads/functional-query/queries/QueryTest/decimal.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/functional-query/queries/QueryTest/decimal.test b/testdata/workloads/functional-query/queries/QueryTest/decimal.test
index e2958df..ac7f1c1 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/decimal.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/decimal.test
@@ -366,17 +366,6 @@ select sample(d1) from decimal_tbl;
 STRING
 ====
 ---- QUERY
-# IMPALA-1837: Handle loss of precision when implicitly casting a literal to a decimal.
-# Here "1.8" will be implicitly cast to a decimal(38,38), losing precision.
-# No error is reported because the overflowed expr is never evaluated.
-select coalesce(cast(0 as decimal(38,38)), 1.8)
----- TYPES
-DECIMAL
----- RESULTS
-0.00000000000000000000000000000000000000
----- ERRORS
-====
----- QUERY
 # IMPALA-2259 - wrong overload chosen for analytic function.
 select lag(c1, 1) over (order by c1), c1
 from decimal_tiny