diff --git a/backends-velox/src/test/resources/tpch-data-parquet-velox/customer/part-00000-bcd9d89f-3bff-48e1-9498-e7f4a9cd8b0c-c000.snappy.parquet b/backends-velox/src/test/resources/tpch-data-parquet-velox/customer/part-00000-a1a42661-7a85-42da-b831-f489a5545d61-c000.snappy.parquet similarity index 92% rename from backends-velox/src/test/resources/tpch-data-parquet-velox/customer/part-00000-bcd9d89f-3bff-48e1-9498-e7f4a9cd8b0c-c000.snappy.parquet rename to backends-velox/src/test/resources/tpch-data-parquet-velox/customer/part-00000-a1a42661-7a85-42da-b831-f489a5545d61-c000.snappy.parquet index 9b6670cc3036..e1e8de37698c 100644 Binary files a/backends-velox/src/test/resources/tpch-data-parquet-velox/customer/part-00000-bcd9d89f-3bff-48e1-9498-e7f4a9cd8b0c-c000.snappy.parquet and b/backends-velox/src/test/resources/tpch-data-parquet-velox/customer/part-00000-a1a42661-7a85-42da-b831-f489a5545d61-c000.snappy.parquet differ diff --git a/backends-velox/src/test/resources/tpch-data-parquet-velox/lineitem/part-00000-488993f4-f7ee-41c7-ac6f-b77edaaf70bb-c000.snappy.parquet b/backends-velox/src/test/resources/tpch-data-parquet-velox/lineitem/part-00000-6c374e0a-7d76-401b-8458-a8e31f8ab704-c000.snappy.parquet similarity index 80% rename from backends-velox/src/test/resources/tpch-data-parquet-velox/lineitem/part-00000-488993f4-f7ee-41c7-ac6f-b77edaaf70bb-c000.snappy.parquet rename to backends-velox/src/test/resources/tpch-data-parquet-velox/lineitem/part-00000-6c374e0a-7d76-401b-8458-a8e31f8ab704-c000.snappy.parquet index bb4709753c72..42d7c0d9f7e0 100644 Binary files a/backends-velox/src/test/resources/tpch-data-parquet-velox/lineitem/part-00000-488993f4-f7ee-41c7-ac6f-b77edaaf70bb-c000.snappy.parquet and b/backends-velox/src/test/resources/tpch-data-parquet-velox/lineitem/part-00000-6c374e0a-7d76-401b-8458-a8e31f8ab704-c000.snappy.parquet differ diff --git a/backends-velox/src/test/resources/tpch-data-parquet-velox/nation/part-00000-e1640808-5e3f-4117-8c30-2cdc65466725-c000.snappy.parquet b/backends-velox/src/test/resources/tpch-data-parquet-velox/nation/part-00000-8a852c7b-da96-4425-9ce8-d188f97f3afe-c000.snappy.parquet similarity index 89% rename from backends-velox/src/test/resources/tpch-data-parquet-velox/nation/part-00000-e1640808-5e3f-4117-8c30-2cdc65466725-c000.snappy.parquet rename to backends-velox/src/test/resources/tpch-data-parquet-velox/nation/part-00000-8a852c7b-da96-4425-9ce8-d188f97f3afe-c000.snappy.parquet index e74361d5d962..7c9a4404a482 100644 Binary files a/backends-velox/src/test/resources/tpch-data-parquet-velox/nation/part-00000-e1640808-5e3f-4117-8c30-2cdc65466725-c000.snappy.parquet and b/backends-velox/src/test/resources/tpch-data-parquet-velox/nation/part-00000-8a852c7b-da96-4425-9ce8-d188f97f3afe-c000.snappy.parquet differ diff --git a/backends-velox/src/test/resources/tpch-data-parquet-velox/orders/part-00000-f397d2a2-f728-40dc-ae3e-6e9302208658-c000.snappy.parquet b/backends-velox/src/test/resources/tpch-data-parquet-velox/orders/part-00000-41cc94ee-a98d-4103-83b1-0b5bcebe03eb-c000.snappy.parquet similarity index 81% rename from backends-velox/src/test/resources/tpch-data-parquet-velox/orders/part-00000-f397d2a2-f728-40dc-ae3e-6e9302208658-c000.snappy.parquet rename to backends-velox/src/test/resources/tpch-data-parquet-velox/orders/part-00000-41cc94ee-a98d-4103-83b1-0b5bcebe03eb-c000.snappy.parquet index 90ab37216c9a..e164929bd49d 100644 Binary files a/backends-velox/src/test/resources/tpch-data-parquet-velox/orders/part-00000-f397d2a2-f728-40dc-ae3e-6e9302208658-c000.snappy.parquet and b/backends-velox/src/test/resources/tpch-data-parquet-velox/orders/part-00000-41cc94ee-a98d-4103-83b1-0b5bcebe03eb-c000.snappy.parquet differ diff --git a/backends-velox/src/test/resources/tpch-data-parquet-velox/part/part-00000-83d7f278-8566-433b-aa62-f62509046461-c000.snappy.parquet b/backends-velox/src/test/resources/tpch-data-parquet-velox/part/part-00000-e664e655-0ada-4e0b-a8aa-213d1e4c3797-c000.snappy.parquet similarity index 90% rename from backends-velox/src/test/resources/tpch-data-parquet-velox/part/part-00000-83d7f278-8566-433b-aa62-f62509046461-c000.snappy.parquet rename to backends-velox/src/test/resources/tpch-data-parquet-velox/part/part-00000-e664e655-0ada-4e0b-a8aa-213d1e4c3797-c000.snappy.parquet index 2835d1b1348f..4763bc361c19 100644 Binary files a/backends-velox/src/test/resources/tpch-data-parquet-velox/part/part-00000-83d7f278-8566-433b-aa62-f62509046461-c000.snappy.parquet and b/backends-velox/src/test/resources/tpch-data-parquet-velox/part/part-00000-e664e655-0ada-4e0b-a8aa-213d1e4c3797-c000.snappy.parquet differ diff --git a/backends-velox/src/test/resources/tpch-data-parquet-velox/partsupp/part-00000-ed5dac84-e8be-4434-9bfb-88d254425f36-c000.snappy.parquet b/backends-velox/src/test/resources/tpch-data-parquet-velox/partsupp/part-00000-2c7e524c-3f91-4228-b003-64ad2c8059a1-c000.snappy.parquet similarity index 90% rename from backends-velox/src/test/resources/tpch-data-parquet-velox/partsupp/part-00000-ed5dac84-e8be-4434-9bfb-88d254425f36-c000.snappy.parquet rename to backends-velox/src/test/resources/tpch-data-parquet-velox/partsupp/part-00000-2c7e524c-3f91-4228-b003-64ad2c8059a1-c000.snappy.parquet index 69b36cb65333..3362ea3275fd 100644 Binary files a/backends-velox/src/test/resources/tpch-data-parquet-velox/partsupp/part-00000-ed5dac84-e8be-4434-9bfb-88d254425f36-c000.snappy.parquet and b/backends-velox/src/test/resources/tpch-data-parquet-velox/partsupp/part-00000-2c7e524c-3f91-4228-b003-64ad2c8059a1-c000.snappy.parquet differ diff --git a/backends-velox/src/test/resources/tpch-data-parquet-velox/region/part-00000-563caa23-ec77-4ab6-b435-5a29e062f7ef-c000.snappy.parquet b/backends-velox/src/test/resources/tpch-data-parquet-velox/region/part-00000-90d7c5d9-46eb-4bf3-8f00-6eee7436761d-c000.snappy.parquet similarity index 95% rename from backends-velox/src/test/resources/tpch-data-parquet-velox/region/part-00000-563caa23-ec77-4ab6-b435-5a29e062f7ef-c000.snappy.parquet rename to backends-velox/src/test/resources/tpch-data-parquet-velox/region/part-00000-90d7c5d9-46eb-4bf3-8f00-6eee7436761d-c000.snappy.parquet index 228bdd88e4a1..dea986b42af1 100644 Binary files a/backends-velox/src/test/resources/tpch-data-parquet-velox/region/part-00000-563caa23-ec77-4ab6-b435-5a29e062f7ef-c000.snappy.parquet and b/backends-velox/src/test/resources/tpch-data-parquet-velox/region/part-00000-90d7c5d9-46eb-4bf3-8f00-6eee7436761d-c000.snappy.parquet differ diff --git a/backends-velox/src/test/resources/tpch-data-parquet-velox/supplier/part-00000-2c7a15d7-f7d1-462e-8c35-bcef6045c34d-c000.snappy.parquet b/backends-velox/src/test/resources/tpch-data-parquet-velox/supplier/part-00000-0a763951-8a7b-4d7f-a34a-c97e9b4859f0-c000.snappy.parquet similarity index 65% rename from backends-velox/src/test/resources/tpch-data-parquet-velox/supplier/part-00000-2c7a15d7-f7d1-462e-8c35-bcef6045c34d-c000.snappy.parquet rename to backends-velox/src/test/resources/tpch-data-parquet-velox/supplier/part-00000-0a763951-8a7b-4d7f-a34a-c97e9b4859f0-c000.snappy.parquet index 9db0b821922f..b72e647f445f 100644 Binary files a/backends-velox/src/test/resources/tpch-data-parquet-velox/supplier/part-00000-2c7a15d7-f7d1-462e-8c35-bcef6045c34d-c000.snappy.parquet and b/backends-velox/src/test/resources/tpch-data-parquet-velox/supplier/part-00000-0a763951-8a7b-4d7f-a34a-c97e9b4859f0-c000.snappy.parquet differ diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q01.sql b/backends-velox/src/test/resources/tpch-queries-velox/q01.sql index d79520c689b9..0c77db75ae2a 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q01.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q01.sql @@ -15,7 +15,7 @@ select from lineitem where - l_shipdate <= '1998-9-01' + l_shipdate <= date '1998-12-01' - interval '90' day group by l_returnflag, l_linestatus diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q03.sql b/backends-velox/src/test/resources/tpch-queries-velox/q03.sql index 6a788873d3aa..c30c5280eafb 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q03.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q03.sql @@ -14,8 +14,8 @@ where c_mktsegment = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey - and o_orderdate < '1995-03-15' - and l_shipdate > '1995-03-15' + and o_orderdate < date '1995-03-15' + and l_shipdate > date '1995-03-15' group by l_orderkey, o_orderdate, diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q04.sql b/backends-velox/src/test/resources/tpch-queries-velox/q04.sql index 05d80c3c00bb..659f6f5d6e8b 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q04.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q04.sql @@ -7,8 +7,8 @@ select from orders where - o_orderdate >= '1993-07-01' - and o_orderdate < '1993-10-01' + o_orderdate >= date '1993-07-01' + and o_orderdate < date '1993-07-01' + interval '3' month and exists ( select * diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q05.sql b/backends-velox/src/test/resources/tpch-queries-velox/q05.sql index 44a5dd8a8348..bc6fece2556f 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q05.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q05.sql @@ -19,8 +19,8 @@ where and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = 'ASIA' - and o_orderdate >= '1994-01-01' - and o_orderdate < '1995-01-01' + and o_orderdate >= date '1994-01-01' + and o_orderdate < date '1994-01-01' + interval '1' year group by n_name order by diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q06.sql b/backends-velox/src/test/resources/tpch-queries-velox/q06.sql index 133a11c0f463..92496dac4f4b 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q06.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q06.sql @@ -6,7 +6,7 @@ select from lineitem where - l_shipdate >= '1994-01-01' - and l_shipdate < '1995-01-01' + l_shipdate >= date '1994-01-01' + and l_shipdate < date '1994-01-01' + interval '1' year and l_discount between .06 - 0.01 and .06 + 0.01 and l_quantity < 24 diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q07.sql b/backends-velox/src/test/resources/tpch-queries-velox/q07.sql index 4a13435f4d01..eb3c51c9ba36 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q07.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q07.sql @@ -30,7 +30,7 @@ from (n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY') or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE') ) - and l_shipdate between '1995-01-01' and '1996-12-31' + and l_shipdate between date '1995-01-01' and date '1996-12-31' ) as shipping group by supp_nation, diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q08.sql b/backends-velox/src/test/resources/tpch-queries-velox/q08.sql index 7837f7f3b432..ca15ebf0bfa8 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q08.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q08.sql @@ -31,7 +31,7 @@ from and n1.n_regionkey = r_regionkey and r_name = 'AMERICA' and s_nationkey = n2.n_nationkey - and o_orderdate between '1995-01-01' and '1996-12-31' + and o_orderdate between date '1995-01-01' and date '1996-12-31' and p_type = 'ECONOMY ANODIZED STEEL' ) as all_nations group by diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q10.sql b/backends-velox/src/test/resources/tpch-queries-velox/q10.sql index 186238af4776..b8437039b719 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q10.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q10.sql @@ -18,8 +18,8 @@ from where c_custkey = o_custkey and l_orderkey = o_orderkey - and o_orderdate >= '1993-10-01' - and o_orderdate < '1994-01-01' + and o_orderdate >= date '1993-10-01' + and o_orderdate < date '1993-10-01' + interval '3' month and l_returnflag = 'R' and c_nationkey = n_nationkey group by diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q12.sql b/backends-velox/src/test/resources/tpch-queries-velox/q12.sql index 8e46ec8416cc..810cc56d4db7 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q12.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q12.sql @@ -23,8 +23,8 @@ where and l_shipmode in ('MAIL', 'SHIP') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate - and l_receiptdate >= '1994-01-01' - and l_receiptdate < '1995-01-01' + and l_receiptdate >= date '1994-01-01' + and l_receiptdate < date '1994-01-01' + interval '1' year group by l_shipmode order by diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q14.sql b/backends-velox/src/test/resources/tpch-queries-velox/q14.sql index f8a0af24c583..0ad826f3ddf7 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q14.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q14.sql @@ -12,5 +12,5 @@ from part where l_partkey = p_partkey - and l_shipdate >= '1995-09-01' - and l_shipdate < '1995-10-01' + and l_shipdate >= date '1995-09-01' + and l_shipdate < date '1995-09-01' + interval '1' month diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q15.sql b/backends-velox/src/test/resources/tpch-queries-velox/q15.sql index 6d8806134856..64d0b48ec09a 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q15.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q15.sql @@ -7,8 +7,8 @@ with revenue0 as from lineitem where - l_shipdate >= '1996-01-01' - and l_shipdate < '1996-04-01' + l_shipdate >= date '1996-01-01' + and l_shipdate < date '1996-01-01' + interval '3' month group by l_suppkey) diff --git a/backends-velox/src/test/resources/tpch-queries-velox/q20.sql b/backends-velox/src/test/resources/tpch-queries-velox/q20.sql index dbbfa8cbc61a..a7b8706b407b 100644 --- a/backends-velox/src/test/resources/tpch-queries-velox/q20.sql +++ b/backends-velox/src/test/resources/tpch-queries-velox/q20.sql @@ -30,8 +30,8 @@ where where l_partkey = ps_partkey and l_suppkey = ps_suppkey - and l_shipdate >= '1994-01-01' - and l_shipdate < '1995-01-01' + and l_shipdate >= date '1994-01-01' + and l_shipdate < date '1994-01-01' + interval '1' year ) ) and s_nationkey = n_nationkey diff --git a/backends-velox/src/test/scala/io/glutenproject/execution/TestOperator.scala b/backends-velox/src/test/scala/io/glutenproject/execution/TestOperator.scala index 81804e362f9c..d9a9c93dc5cf 100644 --- a/backends-velox/src/test/scala/io/glutenproject/execution/TestOperator.scala +++ b/backends-velox/src/test/scala/io/glutenproject/execution/TestOperator.scala @@ -432,6 +432,25 @@ class TestOperator extends WholeStageTransformerSuite { } } + test("nested decimal arithmetics") { + runQueryAndCompare(""" + |SELECT + | l_orderkey, + | SUM( + | (l_extendedprice * (1 - l_discount)) + + | (l_extendedprice * (1 - l_discount) * 0.05) + | ) AS total_revenue_with_tax + |FROM + | lineitem + |GROUP BY + | l_orderkey + |ORDER BY + | l_orderkey + |""".stripMargin) { + checkOperatorMatch[HashAggregateExecTransformer] + } + } + test("Cast double to decimal") { val d = 0.034567890 val df = Seq(d, d, d, d, d, d, d, d, d, d).toDF("DecimalCol") diff --git a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc index 7573c27e7287..e1dcf9b156e0 100644 --- a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc +++ b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc @@ -305,6 +305,12 @@ bool SubstraitToVeloxPlanValidator::validateCast( logValidateMsg("native validation failed due to: Casting from DATE to TIMESTAMP is not supported."); return false; } + if (toType->kind() != TypeKind::VARCHAR) { + logValidateMsg(fmt::format( + "native validation failed due to: Casting from DATE to {} is not supported.", toType->toString())); + return false; + } + break; } case TypeKind::TIMESTAMP: { logValidateMsg(