diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q1.output.hash b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q1.output.hash index 2d33a627d0b..74f1f32ede1 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q1.output.hash +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q1.output.hash @@ -15,4 +15,4 @@ * limitations under the License. */ --2130215201 +-1796738616 diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q1.sql b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q1.sql index 5031eb86c10..b9b382350a2 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q1.sql +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q1.sql @@ -19,13 +19,13 @@ select l_returnflag, l_linestatus, - sum(l_quantity) as sum_qty, - sum(l_extendedprice) as sum_base_price, - sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, - sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, - avg(l_quantity) as avg_qty, - avg(l_extendedprice) as avg_price, - avg(l_discount) as avg_disc, + round(sum(l_quantity), 2) as sum_qty, + round(sum(l_extendedprice), 2) as sum_base_price, + round(sum(l_extendedprice * (1 - l_discount)), 2) as sum_disc_price, + round(sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)), 2) as sum_charge, + round(avg(l_quantity), 2) as avg_qty, + round(avg(l_extendedprice), 2) as avg_price, + round(avg(l_discount), 2) as avg_disc, count(*) as count_order from lineitem diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q10.output.hash b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q10.output.hash index 4a6454e519c..7b922f50772 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q10.output.hash +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q10.output.hash @@ -15,4 +15,4 @@ * limitations under the License. */ --4090660469 +-730770831 diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q10.sql b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q10.sql index 87854a9ad60..89dd5247a1d 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q10.sql +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q10.sql @@ -19,7 +19,7 @@ select c_custkey, c_name, - sum(l_extendedprice * (1 - l_discount)) as revenue, + round(sum(l_extendedprice * (1 - l_discount)), 1) as revenue, c_acctbal, n_name, c_address, diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q14.output.hash b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q14.output.hash index 1b8cf626c59..e0595360402 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q14.output.hash +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q14.output.hash @@ -15,4 +15,4 @@ * limitations under the License. */ -47333415 +799857942 diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q14.sql b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q14.sql index 4c5c485fe30..4aa7d13cab8 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q14.sql +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q14.sql @@ -17,11 +17,11 @@ -- using default substitutions select - 100.00 * sum(case + round(100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) else 0 - end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue + end) / sum(l_extendedprice * (1 - l_discount)), 2) as promo_revenue from lineitem, part diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q15.output.hash b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q15.output.hash index 8dc6c1f42b0..a29b0607dfc 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q15.output.hash +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q15.output.hash @@ -15,4 +15,4 @@ * limitations under the License. */ --2021679095 +-1401614325 diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q15.sql b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q15.sql index 52519586db1..11b9815fedc 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q15.sql +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q15.sql @@ -34,7 +34,7 @@ select s_name, s_address, s_phone, - total_revenue + round(total_revenue, 2) as total_revenue from supplier, revenue0 diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q22.output.hash b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q22.output.hash index d931acdadfa..1d53348d252 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q22.output.hash +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q22.output.hash @@ -15,4 +15,4 @@ * limitations under the License. */ -2111900859 +2123615405 diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q22.sql b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q22.sql index a9dea75f786..d504a839758 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q22.sql +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q22.sql @@ -19,7 +19,7 @@ select cntrycode, count(*) as numcust, - sum(c_acctbal) as totacctbal + round(sum(c_acctbal), 2) as totacctbal from ( select diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q5.output.hash b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q5.output.hash index d608f5fdd77..5320ce21257 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q5.output.hash +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q5.output.hash @@ -15,4 +15,4 @@ * limitations under the License. */ -3717321142 +-2755325540 diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q5.sql b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q5.sql index fc998961c3b..847f372cce5 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q5.sql +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q5.sql @@ -18,7 +18,7 @@ select n_name, - sum(l_extendedprice * (1 - l_discount)) as revenue + round(sum(l_extendedprice * (1 - l_discount)), 2) as revenue from customer, orders, diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q6.output.hash b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q6.output.hash index c9efccd9e0c..fa86974aa11 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q6.output.hash +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q6.output.hash @@ -15,4 +15,4 @@ * limitations under the License. */ -2062248569 +223845550 diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q6.sql b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q6.sql index efd8a50110e..3f9a7209446 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q6.sql +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q6.sql @@ -17,7 +17,7 @@ -- using default substitutions select - sum(l_extendedprice * l_discount) as revenue + round(sum(l_extendedprice * l_discount), 2) as revenue from lineitem where diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q7.output.hash b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q7.output.hash index 02a826f090c..29d09404524 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q7.output.hash +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q7.output.hash @@ -15,4 +15,4 @@ * limitations under the License. */ --1955579146 +-95255706 diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q7.sql b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q7.sql index 3d932e660b5..7c565e6cdf6 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q7.sql +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q7.sql @@ -20,7 +20,7 @@ select supp_nation, cust_nation, l_year, - sum(volume) as revenue + round(sum(volume), 2) as revenue from ( select diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q9.output.hash b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q9.output.hash index 9f13f120a53..561cdadbd5f 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q9.output.hash +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q9.output.hash @@ -15,4 +15,4 @@ * limitations under the License. */ -10861514367 +-12715678387 diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q9.sql b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q9.sql index a5f2d89cb23..8ff49a38a5b 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q9.sql +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/kyuubi/tpch/q9.sql @@ -19,7 +19,7 @@ select nation, o_year, - sum(amount) as sum_profit + round(sum(amount), 2) as sum_profit from ( select diff --git a/extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala b/extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala index a409a5fe927..c651d930043 100644 --- a/extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala +++ b/extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala @@ -31,18 +31,18 @@ import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSessi /** * To run this test suite: * {{{ - * KYUUBI_UPDATE=0 dev/gen/gen_tpcdh_queries.sh + * KYUUBI_UPDATE=0 dev/gen/gen_tpch_queries.sh * }}} * * To re-generate golden files for this suite: * {{{ - * dev/gen/gen_tpcdh_queries.sh + * dev/gen/gen_tpch_queries.sh * }}} */ @Slow class TPCHQuerySuite extends KyuubiFunSuite { - val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet + val queries: List[String] = (1 to 22).map(i => s"q$i").toList test("run query on tiny") { val viewSuffix = "view" @@ -59,20 +59,15 @@ class TPCHQuerySuite extends KyuubiFunSuite { in.close() queryName -> queryContent }.foreach { case (name, sql) => - try { - val result = spark.sql(sql).collect() - val schema = spark.sql(sql).schema - val schemaDDL = LICENSE_HEADER + schema.toDDL + "\n" - spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix") - val sumHashResult = LICENSE_HEADER + spark.sql( - s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0) + "\n" - val tuple = generateGoldenFiles("kyuubi/tpch", name, schemaDDL, sumHashResult) - assert(schemaDDL == tuple._1) - assert(sumHashResult == tuple._2) - } catch { - case cause: Throwable => - fail(name, cause) - } + val result = spark.sql(sql).collect() + val schema = spark.sql(sql).schema + val schemaDDL = LICENSE_HEADER + schema.toDDL + "\n" + spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix") + val sumHashResult = LICENSE_HEADER + spark.sql( + s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0) + "\n" + val tuple = generateGoldenFiles("kyuubi/tpch", name, schemaDDL, sumHashResult) + assert(schemaDDL == tuple._1, s"query $name schema not match") + assert(sumHashResult == tuple._2, s"query $name result not match") } } }