You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/06/02 07:07:57 UTC
[GitHub] [incubator-kyuubi] jiaoqingbo opened a new pull request, #2806: [KYUUBI #2805] add TPC-H queries verification
jiaoqingbo opened a new pull request, #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806
<!--
Thanks for sending a pull request!
Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
-->
### _Why are the changes needed?_
<!--
Please clarify why the changes are needed. For instance,
1. If you add a feature, you can talk about the use case of it.
2. If you fix a bug, you can clarify why it is a bug.
-->
fix #2805
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] jiaoqingbo commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
jiaoqingbo commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r892151976
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.{Files, Path, Paths}
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.tags.TpchTest
+
+// scalastyle:off line.size.limit
+/**
+ * To run this test suite:
+ * {{{
+ * build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ *
+ * To re-generate golden files for this suite:
+ * {{{
+ * KYUUBI_UPDATE=1 build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ */
+// scalastyle:on line.size.limit
+
+@TpchTest
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ private val regenerateGoldenFiles = sys.env.get("KYUUBI_UPDATE").contains("1")
+
+ val baseResourcePath: Path =
+ Paths.get("extensions", "spark", "kyuubi-spark-connector-tpch", "src", "main", "resources")
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q1" -> -2130215201L,
+ "q2" -> 2296723790L,
+ "q3" -> -4118618460L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q6" -> 2062248569L,
+ "q7" -> -1955579146L,
+ "q8" -> 453239528L,
+ "q9" -> 10861514367L,
+ "q10" -> -4090660469L,
+ "q11" -> -21773379672L,
+ "q12" -> 2455990065L,
+ "q13" -> -1379884230L,
+ "q14" -> 47333415L,
+ "q15" -> -2021679095L,
+ "q16" -> 326972717L,
+ "q17" -> 42L,
+ "q18" -> 1596157524L,
+ "q19" -> -1061725826L,
+ "q20" -> -35851308L,
+ "q21" -> 1407638530L,
+ "q22" -> 2111900859L)
+
+ private def fileToString(file: Path): String = {
+ new String(Files.readAllBytes(file), StandardCharsets.UTF_8)
+ }
+
+ test("run query on tiny") {
+ val viewSuffix = "view";
+ val sparkConf = new SparkConf().setMaster("local[*]")
+ .set("spark.ui.enabled", "false")
+ .set("spark.sql.catalogImplementation", "in-memory")
+ .set("spark.sql.catalog.tpch", classOf[TPCHCatalog].getName)
+ withSparkSession(SparkSession.builder.config(sparkConf).getOrCreate()) { spark =>
+ spark.sql("USE tpch.tiny")
+ queries.map { queryName =>
+ val in = getClass.getClassLoader.getResourceAsStream(
+ s"tpch/sql/$queryName.sql")
+ val queryContent: String = Source.fromInputStream(in)(Codec.UTF8).mkString
+ in.close()
+ queryName -> queryContent
+ }.foreach { case (name, sql) =>
+ try {
+ val result = spark.sql(sql).collect()
+ val schema = spark.sql(sql).schema
+ val schemaDDL = schema.toDDL + "\n"
+ spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix")
+ val sumHashResult =
+ spark.sql(s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0)
+
+ val goldenFile = Paths.get(
+ baseResourcePath.toFile.getAbsolutePath,
+ "tpch",
+ "schema",
+ s"${name.stripSuffix(".sql")}.output.schema")
+
+ if (regenerateGoldenFiles) {
+ Files.write(goldenFile, schemaDDL.getBytes)
Review Comment:

Some other schema files don't seem to have added headers either.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] jiaoqingbo commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
jiaoqingbo commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r892124573
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.{Files, Path, Paths}
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.tags.TpchTest
+
+// scalastyle:off line.size.limit
+/**
+ * To run this test suite:
+ * {{{
+ * build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ *
+ * To re-generate golden files for this suite:
+ * {{{
+ * KYUUBI_UPDATE=1 build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ */
+// scalastyle:on line.size.limit
+
+@TpchTest
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ private val regenerateGoldenFiles = sys.env.get("KYUUBI_UPDATE").contains("1")
+
+ val baseResourcePath: Path =
+ Paths.get("extensions", "spark", "kyuubi-spark-connector-tpch", "src", "main", "resources")
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q1" -> -2130215201L,
+ "q2" -> 2296723790L,
+ "q3" -> -4118618460L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q6" -> 2062248569L,
+ "q7" -> -1955579146L,
+ "q8" -> 453239528L,
+ "q9" -> 10861514367L,
+ "q10" -> -4090660469L,
+ "q11" -> -21773379672L,
+ "q12" -> 2455990065L,
+ "q13" -> -1379884230L,
+ "q14" -> 47333415L,
+ "q15" -> -2021679095L,
+ "q16" -> 326972717L,
+ "q17" -> 42L,
+ "q18" -> 1596157524L,
+ "q19" -> -1061725826L,
+ "q20" -> -35851308L,
+ "q21" -> 1407638530L,
+ "q22" -> 2111900859L)
+
+ private def fileToString(file: Path): String = {
+ new String(Files.readAllBytes(file), StandardCharsets.UTF_8)
+ }
+
+ test("run query on tiny") {
+ val viewSuffix = "view";
+ val sparkConf = new SparkConf().setMaster("local[*]")
+ .set("spark.ui.enabled", "false")
+ .set("spark.sql.catalogImplementation", "in-memory")
+ .set("spark.sql.catalog.tpch", classOf[TPCHCatalog].getName)
+ withSparkSession(SparkSession.builder.config(sparkConf).getOrCreate()) { spark =>
+ spark.sql("USE tpch.tiny")
+ queries.map { queryName =>
+ val in = getClass.getClassLoader.getResourceAsStream(
+ s"tpch/sql/$queryName.sql")
+ val queryContent: String = Source.fromInputStream(in)(Codec.UTF8).mkString
+ in.close()
+ queryName -> queryContent
+ }.foreach { case (name, sql) =>
+ try {
+ val result = spark.sql(sql).collect()
+ val schema = spark.sql(sql).schema
+ val schemaDDL = schema.toDDL + "\n"
+ spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix")
+ val sumHashResult =
+ spark.sql(s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0)
+
+ val goldenFile = Paths.get(
+ baseResourcePath.toFile.getAbsolutePath,
+ "tpch",
+ "schema",
+ s"${name.stripSuffix(".sql")}.output.schema")
+
+ if (regenerateGoldenFiles) {
+ Files.write(goldenFile, schemaDDL.getBytes)
+ }
+ val expectedSchema = fileToString(goldenFile)
+
+ // scalastyle:off
+ println(
Review Comment:
I found that the execution on CI reports an error but there is no problem with local execution. Need some log info, I'll delete it later
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#issuecomment-1150808720
Thanks, merging to master
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2806: [KYUUBI #2805] add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r890736536
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.spark.connector.common.SparkUtils
+
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q11" -> -21773379672L,
+ "q7" -> -1955579146L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q20" -> -35851308L,
+ "q3" -> -4118618460L,
+ "q19" -> -1061725826L,
+ "q9" -> 10861514367L,
+ "q15" -> -2021679095L,
+ "q10" -> -4090660469L,
+ "q22" -> 2111900859L,
+ "q18" -> 1596157524L,
+ "q21" -> 1407638530L,
+ "q14" -> 47333415L,
+ "q2" -> 2296723790L,
+ "q13" -> -1379884230L,
+ "q17" -> 42L,
+ "q1" -> -2130215201L,
+ "q8" -> 453239528L,
+ "q6" -> 2062248569L,
+ "q12" -> 2455990065L,
+ "q16" -> 326972717L)
+
+ val queryToUnchangedSchema: Map[String, String] = Map(
+ "q11" -> "`ps_partkey` BIGINT,`value` DOUBLE",
+ "q7" -> "`supp_nation` STRING,`cust_nation` STRING,`l_year` INT,`revenue` DOUBLE",
+ "q5" -> "`n_name` STRING,`revenue` DOUBLE",
+ "q20" -> "`s_name` STRING,`s_address` STRING",
+ "q3" -> "`l_orderkey` BIGINT,`revenue` DOUBLE,`o_orderdate` DATE,`o_shippriority` INT",
+ "q19" -> "`revenue` DOUBLE",
+ "q9" -> "`nation` STRING,`o_year` INT,`sum_profit` DOUBLE",
+ "q15" -> ("`s_suppkey` BIGINT,`s_name` STRING,`s_address` STRING," +
+ "`s_phone` STRING,`total_revenue` DOUBLE"),
+ "q10" -> ("`c_custkey` BIGINT,`c_name` STRING,`revenue` DOUBLE," +
+ "`c_acctbal` DOUBLE,`n_name` STRING,`c_address` STRING,`c_phone` STRING,`c_comment` STRING"),
+ "q18" -> ("`c_name` STRING,`c_custkey` BIGINT,`o_orderkey` BIGINT," +
+ "`o_orderdate` DATE,`o_totalprice` DOUBLE,`sum(l_quantity)` DOUBLE"),
+ "q14" -> "`promo_revenue` DOUBLE",
+ "q2" -> ("`s_acctbal` DOUBLE,`s_name` STRING,`n_name` STRING," +
+ "`p_partkey` BIGINT,`p_mfgr` STRING,`s_address` STRING,`s_phone` STRING,`s_comment` STRING"),
+ "q17" -> "`avg_yearly` DOUBLE",
+ "q8" -> "`o_year` INT,`mkt_share` DOUBLE",
+ "q6" -> "`revenue` DOUBLE",
+ "q12" -> "`l_shipmode` STRING,`high_line_count` BIGINT,`low_line_count` BIGINT")
+
+ val queryToSchema_3_2: Map[String, String] = queryToUnchangedSchema ++ Map(
+ "q4" -> "`o_orderpriority` STRING,`order_count` BIGINT NOT NULL",
+ "q22" -> "`cntrycode` STRING,`numcust` BIGINT NOT NULL,`totacctbal` DOUBLE",
+ "q21" -> "`s_name` STRING,`numwait` BIGINT NOT NULL",
+ "q13" -> "`c_count` BIGINT NOT NULL,`custdist` BIGINT NOT NULL",
+ "q1" -> ("`l_returnflag` STRING,`l_linestatus` STRING,`sum_qty` DOUBLE," +
+ "`sum_base_price` DOUBLE,`sum_disc_price` DOUBLE,`sum_charge` DOUBLE," +
+ "`avg_qty` DOUBLE,`avg_price` DOUBLE,`avg_disc` DOUBLE,`count_order` BIGINT NOT NULL"),
+ "q16" -> "`p_brand` STRING,`p_type` STRING,`p_size` INT,`supplier_cnt` BIGINT NOT NULL")
+
+ val queryToSchema: Map[String, String] = queryToUnchangedSchema ++ Map(
+ "q4" -> "`o_orderpriority` STRING,`order_count` BIGINT",
+ "q22" -> "`cntrycode` STRING,`numcust` BIGINT,`totacctbal` DOUBLE",
+ "q21" -> "`s_name` STRING,`numwait` BIGINT",
+ "q13" -> "`c_count` BIGINT,`custdist` BIGINT",
+ "q1" -> ("`l_returnflag` STRING,`l_linestatus` STRING,`sum_qty` DOUBLE," +
+ "`sum_base_price` DOUBLE,`sum_disc_price` DOUBLE,`sum_charge` DOUBLE," +
+ "`avg_qty` DOUBLE,`avg_price` DOUBLE,`avg_disc` DOUBLE,`count_order` BIGINT"),
+ "q16" -> "`p_brand` STRING,`p_type` STRING,`p_size` INT,`supplier_cnt` BIGINT")
+
+ test("run query on tiny") {
+ val viewSuffix = "view";
+ val sparkConf = new SparkConf().setMaster("local[*]")
+ .set("spark.ui.enabled", "false")
+ .set("spark.sql.catalogImplementation", "in-memory")
+ .set("spark.sql.catalog.tpch", classOf[TPCHCatalog].getName)
+ withSparkSession(SparkSession.builder.config(sparkConf).getOrCreate()) { spark =>
+ spark.sql("USE tpch.tiny")
+ queries.map { queryName =>
+ val in = getClass.getClassLoader.getResourceAsStream(
+ s"tpch/$queryName.sql")
+ val queryContent: String = Source.fromInputStream(in)(Codec.UTF8).mkString
+ in.close()
+ queryName -> queryContent
+ }.foreach { case (name, sql) =>
+ try {
+ val result = spark.sql(sql).collect()
+ val schema = spark.sql(sql).schema
+ spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix")
+ val sumHashResult =
+ spark.sql(s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0)
+ // scalastyle:off
+ println(s"name=$name,schema=${schema.toDDL},sumHashResult=$sumHashResult")
+ // scalastyle:on
+ assert(sumHashResult == queryToSumHash(name))
+ if (SparkUtils.isSparkVersionEqualTo("3.3")) {
+ // The toDDL method of StructType, the return value in spark3.3
+ // is different from that in spark3.2
+ // in spark3.2 "`a` INT"
+ // in spark3.3 "a INT"
Review Comment:
anther option is maitain the output schema in seprate files like `OutputSchemaTPCDSSuite` does.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2806: [KYUUBI #2805] add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r890734940
##########
extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/tpch/q1.sql:
##########
@@ -0,0 +1,39 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- using default substitutions
+
+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,
+ count(*) as count_order
Review Comment:
please use spaces instead of tab
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2806: [KYUUBI #2805] add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r890735213
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.spark.connector.common.SparkUtils
+
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q11" -> -21773379672L,
+ "q7" -> -1955579146L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q20" -> -35851308L,
+ "q3" -> -4118618460L,
+ "q19" -> -1061725826L,
+ "q9" -> 10861514367L,
+ "q15" -> -2021679095L,
+ "q10" -> -4090660469L,
+ "q22" -> 2111900859L,
+ "q18" -> 1596157524L,
+ "q21" -> 1407638530L,
+ "q14" -> 47333415L,
+ "q2" -> 2296723790L,
+ "q13" -> -1379884230L,
+ "q17" -> 42L,
+ "q1" -> -2130215201L,
+ "q8" -> 453239528L,
+ "q6" -> 2062248569L,
+ "q12" -> 2455990065L,
+ "q16" -> 326972717L)
Review Comment:
could u pls ordering them by name?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r892125716
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.{Files, Path, Paths}
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.tags.TpchTest
+
+// scalastyle:off line.size.limit
+/**
+ * To run this test suite:
+ * {{{
+ * build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ *
+ * To re-generate golden files for this suite:
+ * {{{
+ * KYUUBI_UPDATE=1 build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ */
+// scalastyle:on line.size.limit
+
+@TpchTest
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ private val regenerateGoldenFiles = sys.env.get("KYUUBI_UPDATE").contains("1")
+
+ val baseResourcePath: Path =
+ Paths.get("extensions", "spark", "kyuubi-spark-connector-tpch", "src", "main", "resources")
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q1" -> -2130215201L,
+ "q2" -> 2296723790L,
+ "q3" -> -4118618460L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q6" -> 2062248569L,
+ "q7" -> -1955579146L,
+ "q8" -> 453239528L,
+ "q9" -> 10861514367L,
+ "q10" -> -4090660469L,
+ "q11" -> -21773379672L,
+ "q12" -> 2455990065L,
+ "q13" -> -1379884230L,
+ "q14" -> 47333415L,
+ "q15" -> -2021679095L,
+ "q16" -> 326972717L,
+ "q17" -> 42L,
+ "q18" -> 1596157524L,
+ "q19" -> -1061725826L,
+ "q20" -> -35851308L,
+ "q21" -> 1407638530L,
+ "q22" -> 2111900859L)
+
+ private def fileToString(file: Path): String = {
+ new String(Files.readAllBytes(file), StandardCharsets.UTF_8)
+ }
+
+ test("run query on tiny") {
+ val viewSuffix = "view";
Review Comment:
I'm re-orignizing the kyuubi testing workflow, and I'm going to mark it w/ `org.scalatest.tags.Slow` tag. Please remove `org.apache.kyuubi.tags.TpchTest` and put `assume(SPARK_MAJOR_MINOR_VERSION == (3, 2)` at the first line of this method for temporary.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r892222182
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.{Files, Path, Paths}
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.tags.TpchTest
+
+// scalastyle:off line.size.limit
+/**
+ * To run this test suite:
+ * {{{
+ * build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ *
+ * To re-generate golden files for this suite:
+ * {{{
+ * KYUUBI_UPDATE=1 build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ */
+// scalastyle:on line.size.limit
+
+@TpchTest
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ private val regenerateGoldenFiles = sys.env.get("KYUUBI_UPDATE").contains("1")
+
+ val baseResourcePath: Path =
+ Paths.get("extensions", "spark", "kyuubi-spark-connector-tpch", "src", "main", "resources")
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q1" -> -2130215201L,
+ "q2" -> 2296723790L,
+ "q3" -> -4118618460L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q6" -> 2062248569L,
+ "q7" -> -1955579146L,
+ "q8" -> 453239528L,
+ "q9" -> 10861514367L,
+ "q10" -> -4090660469L,
+ "q11" -> -21773379672L,
+ "q12" -> 2455990065L,
+ "q13" -> -1379884230L,
+ "q14" -> 47333415L,
+ "q15" -> -2021679095L,
+ "q16" -> 326972717L,
+ "q17" -> 42L,
+ "q18" -> 1596157524L,
+ "q19" -> -1061725826L,
+ "q20" -> -35851308L,
+ "q21" -> 1407638530L,
+ "q22" -> 2111900859L)
+
+ private def fileToString(file: Path): String = {
+ new String(Files.readAllBytes(file), StandardCharsets.UTF_8)
+ }
+
+ test("run query on tiny") {
+ val viewSuffix = "view";
+ val sparkConf = new SparkConf().setMaster("local[*]")
+ .set("spark.ui.enabled", "false")
+ .set("spark.sql.catalogImplementation", "in-memory")
+ .set("spark.sql.catalog.tpch", classOf[TPCHCatalog].getName)
+ withSparkSession(SparkSession.builder.config(sparkConf).getOrCreate()) { spark =>
+ spark.sql("USE tpch.tiny")
+ queries.map { queryName =>
+ val in = getClass.getClassLoader.getResourceAsStream(
+ s"tpch/sql/$queryName.sql")
+ val queryContent: String = Source.fromInputStream(in)(Codec.UTF8).mkString
+ in.close()
+ queryName -> queryContent
+ }.foreach { case (name, sql) =>
+ try {
+ val result = spark.sql(sql).collect()
+ val schema = spark.sql(sql).schema
+ val schemaDDL = schema.toDDL + "\n"
+ spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix")
+ val sumHashResult =
+ spark.sql(s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0)
+
+ val goldenFile = Paths.get(
+ baseResourcePath.toFile.getAbsolutePath,
+ "tpch",
+ "schema",
+ s"${name.stripSuffix(".sql")}.output.schema")
+
+ if (regenerateGoldenFiles) {
+ Files.write(goldenFile, schemaDDL.getBytes)
Review Comment:
I see, we may remove them eventually.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r892121355
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.{Files, Path, Paths}
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.tags.TpchTest
+
+// scalastyle:off line.size.limit
+/**
+ * To run this test suite:
+ * {{{
+ * build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ *
+ * To re-generate golden files for this suite:
+ * {{{
+ * KYUUBI_UPDATE=1 build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ */
+// scalastyle:on line.size.limit
+
+@TpchTest
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ private val regenerateGoldenFiles = sys.env.get("KYUUBI_UPDATE").contains("1")
+
+ val baseResourcePath: Path =
+ Paths.get("extensions", "spark", "kyuubi-spark-connector-tpch", "src", "main", "resources")
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q1" -> -2130215201L,
+ "q2" -> 2296723790L,
+ "q3" -> -4118618460L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q6" -> 2062248569L,
+ "q7" -> -1955579146L,
+ "q8" -> 453239528L,
+ "q9" -> 10861514367L,
+ "q10" -> -4090660469L,
+ "q11" -> -21773379672L,
+ "q12" -> 2455990065L,
+ "q13" -> -1379884230L,
+ "q14" -> 47333415L,
+ "q15" -> -2021679095L,
+ "q16" -> 326972717L,
+ "q17" -> 42L,
+ "q18" -> 1596157524L,
+ "q19" -> -1061725826L,
+ "q20" -> -35851308L,
+ "q21" -> 1407638530L,
+ "q22" -> 2111900859L)
+
+ private def fileToString(file: Path): String = {
+ new String(Files.readAllBytes(file), StandardCharsets.UTF_8)
+ }
+
+ test("run query on tiny") {
+ val viewSuffix = "view";
+ val sparkConf = new SparkConf().setMaster("local[*]")
+ .set("spark.ui.enabled", "false")
+ .set("spark.sql.catalogImplementation", "in-memory")
+ .set("spark.sql.catalog.tpch", classOf[TPCHCatalog].getName)
+ withSparkSession(SparkSession.builder.config(sparkConf).getOrCreate()) { spark =>
+ spark.sql("USE tpch.tiny")
+ queries.map { queryName =>
+ val in = getClass.getClassLoader.getResourceAsStream(
+ s"tpch/sql/$queryName.sql")
+ val queryContent: String = Source.fromInputStream(in)(Codec.UTF8).mkString
+ in.close()
+ queryName -> queryContent
+ }.foreach { case (name, sql) =>
+ try {
+ val result = spark.sql(sql).collect()
+ val schema = spark.sql(sql).schema
+ val schemaDDL = schema.toDDL + "\n"
+ spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix")
+ val sumHashResult =
+ spark.sql(s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0)
+
+ val goldenFile = Paths.get(
+ baseResourcePath.toFile.getAbsolutePath,
+ "tpch",
+ "schema",
+ s"${name.stripSuffix(".sql")}.output.schema")
+
+ if (regenerateGoldenFiles) {
+ Files.write(goldenFile, schemaDDL.getBytes)
+ }
+ val expectedSchema = fileToString(goldenFile)
+
+ // scalastyle:off
+ println(
Review Comment:
Why do we need this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 closed pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 closed pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
URL: https://github.com/apache/incubator-kyuubi/pull/2806
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] jiaoqingbo commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
jiaoqingbo commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r892152588
##########
extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/tpch/sql/q21.sql:
##########
@@ -0,0 +1,58 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- using default substitutions
+
+select
+ s_name,
+ count(*) as numwait
+from
+ supplier,
+ lineitem l1,
+ orders,
+ nation
+where
+ s_suppkey = l1.l_suppkey
+ and o_orderkey = l1.l_orderkey
+ and o_orderstatus = 'F'
+ and l1.l_receiptdate > l1.l_commitdate
+ and exists (
+ select
+ *
+ from
+ lineitem l2
+ where
+ l2.l_orderkey = l1.l_orderkey
+ and l2.l_suppkey <> l1.l_suppkey
+ )
+ and not exists (
+ select
+ *
+ from
+ lineitem l3
+ where
+ l3.l_orderkey = l1.l_orderkey
+ and l3.l_suppkey <> l1.l_suppkey
+ and l3.l_receiptdate > l3.l_commitdate
+ )
+ and s_nationkey = n_nationkey
+ and n_name = 'SAUDI ARABIA'
+group by
+ s_name
+order by
+ numwait desc,
+ s_name
+limit 100
Review Comment:
I will change it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] jiaoqingbo commented on pull request #2806: [KYUUBI #2805] add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
jiaoqingbo commented on PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#issuecomment-1144542665
cc @pan3793
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r892126589
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.{Files, Path, Paths}
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.tags.TpchTest
+
+// scalastyle:off line.size.limit
+/**
+ * To run this test suite:
+ * {{{
+ * build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ *
+ * To re-generate golden files for this suite:
+ * {{{
+ * KYUUBI_UPDATE=1 build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ */
+// scalastyle:on line.size.limit
+
+@TpchTest
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ private val regenerateGoldenFiles = sys.env.get("KYUUBI_UPDATE").contains("1")
+
+ val baseResourcePath: Path =
+ Paths.get("extensions", "spark", "kyuubi-spark-connector-tpch", "src", "main", "resources")
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q1" -> -2130215201L,
+ "q2" -> 2296723790L,
+ "q3" -> -4118618460L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q6" -> 2062248569L,
+ "q7" -> -1955579146L,
+ "q8" -> 453239528L,
+ "q9" -> 10861514367L,
+ "q10" -> -4090660469L,
+ "q11" -> -21773379672L,
+ "q12" -> 2455990065L,
+ "q13" -> -1379884230L,
+ "q14" -> 47333415L,
+ "q15" -> -2021679095L,
+ "q16" -> 326972717L,
+ "q17" -> 42L,
+ "q18" -> 1596157524L,
+ "q19" -> -1061725826L,
+ "q20" -> -35851308L,
+ "q21" -> 1407638530L,
+ "q22" -> 2111900859L)
+
+ private def fileToString(file: Path): String = {
+ new String(Files.readAllBytes(file), StandardCharsets.UTF_8)
+ }
+
+ test("run query on tiny") {
+ val viewSuffix = "view";
+ val sparkConf = new SparkConf().setMaster("local[*]")
+ .set("spark.ui.enabled", "false")
+ .set("spark.sql.catalogImplementation", "in-memory")
+ .set("spark.sql.catalog.tpch", classOf[TPCHCatalog].getName)
+ withSparkSession(SparkSession.builder.config(sparkConf).getOrCreate()) { spark =>
+ spark.sql("USE tpch.tiny")
+ queries.map { queryName =>
+ val in = getClass.getClassLoader.getResourceAsStream(
+ s"tpch/sql/$queryName.sql")
+ val queryContent: String = Source.fromInputStream(in)(Codec.UTF8).mkString
+ in.close()
+ queryName -> queryContent
+ }.foreach { case (name, sql) =>
+ try {
+ val result = spark.sql(sql).collect()
+ val schema = spark.sql(sql).schema
+ val schemaDDL = schema.toDDL + "\n"
+ spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix")
+ val sumHashResult =
+ spark.sql(s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0)
+
+ val goldenFile = Paths.get(
+ baseResourcePath.toFile.getAbsolutePath,
+ "tpch",
+ "schema",
+ s"${name.stripSuffix(".sql")}.output.schema")
+
+ if (regenerateGoldenFiles) {
+ Files.write(goldenFile, schemaDDL.getBytes)
Review Comment:
Maybe we can also write an Apache License header to the golden files.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] jiaoqingbo commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
jiaoqingbo commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r892129542
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.{Files, Path, Paths}
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.tags.TpchTest
+
+// scalastyle:off line.size.limit
+/**
+ * To run this test suite:
+ * {{{
+ * build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ *
+ * To re-generate golden files for this suite:
+ * {{{
+ * KYUUBI_UPDATE=1 build/mvn clean install \
+ * -Dmaven.plugin.scalatest.exclude.tags="" \
+ * -Dtest=none -DwildcardSuites=org.apache.kyuubi.spark.connector.tpch.TPCHQuerySuite
+ * }}}
+ */
+// scalastyle:on line.size.limit
+
+@TpchTest
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ private val regenerateGoldenFiles = sys.env.get("KYUUBI_UPDATE").contains("1")
+
+ val baseResourcePath: Path =
+ Paths.get("extensions", "spark", "kyuubi-spark-connector-tpch", "src", "main", "resources")
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q1" -> -2130215201L,
+ "q2" -> 2296723790L,
+ "q3" -> -4118618460L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q6" -> 2062248569L,
+ "q7" -> -1955579146L,
+ "q8" -> 453239528L,
+ "q9" -> 10861514367L,
+ "q10" -> -4090660469L,
+ "q11" -> -21773379672L,
+ "q12" -> 2455990065L,
+ "q13" -> -1379884230L,
+ "q14" -> 47333415L,
+ "q15" -> -2021679095L,
+ "q16" -> 326972717L,
+ "q17" -> 42L,
+ "q18" -> 1596157524L,
+ "q19" -> -1061725826L,
+ "q20" -> -35851308L,
+ "q21" -> 1407638530L,
+ "q22" -> 2111900859L)
+
+ private def fileToString(file: Path): String = {
+ new String(Files.readAllBytes(file), StandardCharsets.UTF_8)
+ }
+
+ test("run query on tiny") {
+ val viewSuffix = "view";
Review Comment:
Ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] codecov-commenter commented on pull request #2806: [KYUUBI #2805] add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#issuecomment-1147186088
# [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#2806](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ab853fb) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/21845266b3ba80494226039c08758ec506656503?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2184526) will **increase** coverage by `0.11%`.
> The diff coverage is `n/a`.
> :exclamation: Current head ab853fb differs from pull request most recent head 0c238fd. Consider uploading reports for the commit 0c238fd to get more accurate results
```diff
@@ Coverage Diff @@
## master #2806 +/- ##
============================================
+ Coverage 62.89% 63.01% +0.11%
- Complexity 202 205 +3
============================================
Files 481 481
Lines 21376 21425 +49
Branches 2836 2843 +7
============================================
+ Hits 13445 13500 +55
+ Misses 6654 6642 -12
- Partials 1277 1283 +6
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...g/apache/kyuubi/operation/BatchJobSubmission.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vQmF0Y2hKb2JTdWJtaXNzaW9uLnNjYWxh) | `83.05% <0.00%> (-4.19%)` | :arrow_down: |
| [...e/kyuubi/server/statestore/SessionStateStore.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvc3RhdGVzdG9yZS9TZXNzaW9uU3RhdGVTdG9yZS5zY2FsYQ==) | `91.54% <0.00%> (-3.84%)` | :arrow_down: |
| [...g/apache/kyuubi/session/KyuubiSessionManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXNzaW9uL0t5dXViaVNlc3Npb25NYW5hZ2VyLnNjYWxh) | `85.36% <0.00%> (-1.22%)` | :arrow_down: |
| [...in/java/org/apache/kyuubi/client/BatchRestApi.java](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXJlc3QtY2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9reXV1YmkvY2xpZW50L0JhdGNoUmVzdEFwaS5qYXZh) | `100.00% <0.00%> (ø)` | |
| [.../kyuubi/server/statestore/StateStoreProvider.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvc3RhdGVzdG9yZS9TdGF0ZVN0b3JlUHJvdmlkZXIuc2NhbGE=) | | |
| [...apache/kyuubi/server/statestore/api/Metadata.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvc3RhdGVzdG9yZS9hcGkvTWV0YWRhdGEuc2NhbGE=) | | |
| [...kyuubi/server/statestore/api/SessionMetadata.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvc3RhdGVzdG9yZS9hcGkvU2Vzc2lvbk1ldGFkYXRhLnNjYWxh) | `95.23% <0.00%> (ø)` | |
| [...e/kyuubi/client/api/v1/dto/CloseBatchResponse.java](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXJlc3QtY2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9reXV1YmkvY2xpZW50L2FwaS92MS9kdG8vQ2xvc2VCYXRjaFJlc3BvbnNlLmphdmE=) | `72.22% <0.00%> (ø)` | |
| [...i/engine/hive/operation/HiveOperationManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1oaXZlLXNxbC1lbmdpbmUvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvZW5naW5lL2hpdmUvb3BlcmF0aW9uL0hpdmVPcGVyYXRpb25NYW5hZ2VyLnNjYWxh) | `93.87% <0.00%> (+0.39%)` | :arrow_up: |
| [...main/java/org/apache/kyuubi/client/RestClient.java](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXJlc3QtY2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9reXV1YmkvY2xpZW50L1Jlc3RDbGllbnQuamF2YQ==) | `81.35% <0.00%> (+0.65%)` | :arrow_up: |
| ... and [10 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [2184526...0c238fd](https://codecov.io/gh/apache/incubator-kyuubi/pull/2806?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] jiaoqingbo commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
jiaoqingbo commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r890820843
##########
extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/tpch/q1.sql:
##########
@@ -0,0 +1,39 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- using default substitutions
+
+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,
+ count(*) as count_order
Review Comment:
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r892127346
##########
extensions/spark/kyuubi-spark-connector-tpch/src/main/resources/tpch/sql/q21.sql:
##########
@@ -0,0 +1,58 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- using default substitutions
+
+select
+ s_name,
+ count(*) as numwait
+from
+ supplier,
+ lineitem l1,
+ orders,
+ nation
+where
+ s_suppkey = l1.l_suppkey
+ and o_orderkey = l1.l_orderkey
+ and o_orderstatus = 'F'
+ and l1.l_receiptdate > l1.l_commitdate
+ and exists (
+ select
+ *
+ from
+ lineitem l2
+ where
+ l2.l_orderkey = l1.l_orderkey
+ and l2.l_suppkey <> l1.l_suppkey
+ )
+ and not exists (
+ select
+ *
+ from
+ lineitem l3
+ where
+ l3.l_orderkey = l1.l_orderkey
+ and l3.l_suppkey <> l1.l_suppkey
+ and l3.l_receiptdate > l3.l_commitdate
+ )
+ and s_nationkey = n_nationkey
+ and n_name = 'SAUDI ARABIA'
+group by
+ s_name
+order by
+ numwait desc,
+ s_name
+limit 100
Review Comment:
A fews of queries lacks NEWLINE at end of file
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] jiaoqingbo commented on pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
jiaoqingbo commented on PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#issuecomment-1150791574
cc @pan3793
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2806: [KYUUBI #2805] Add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r890736536
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.spark.connector.common.SparkUtils
+
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q11" -> -21773379672L,
+ "q7" -> -1955579146L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q20" -> -35851308L,
+ "q3" -> -4118618460L,
+ "q19" -> -1061725826L,
+ "q9" -> 10861514367L,
+ "q15" -> -2021679095L,
+ "q10" -> -4090660469L,
+ "q22" -> 2111900859L,
+ "q18" -> 1596157524L,
+ "q21" -> 1407638530L,
+ "q14" -> 47333415L,
+ "q2" -> 2296723790L,
+ "q13" -> -1379884230L,
+ "q17" -> 42L,
+ "q1" -> -2130215201L,
+ "q8" -> 453239528L,
+ "q6" -> 2062248569L,
+ "q12" -> 2455990065L,
+ "q16" -> 326972717L)
+
+ val queryToUnchangedSchema: Map[String, String] = Map(
+ "q11" -> "`ps_partkey` BIGINT,`value` DOUBLE",
+ "q7" -> "`supp_nation` STRING,`cust_nation` STRING,`l_year` INT,`revenue` DOUBLE",
+ "q5" -> "`n_name` STRING,`revenue` DOUBLE",
+ "q20" -> "`s_name` STRING,`s_address` STRING",
+ "q3" -> "`l_orderkey` BIGINT,`revenue` DOUBLE,`o_orderdate` DATE,`o_shippriority` INT",
+ "q19" -> "`revenue` DOUBLE",
+ "q9" -> "`nation` STRING,`o_year` INT,`sum_profit` DOUBLE",
+ "q15" -> ("`s_suppkey` BIGINT,`s_name` STRING,`s_address` STRING," +
+ "`s_phone` STRING,`total_revenue` DOUBLE"),
+ "q10" -> ("`c_custkey` BIGINT,`c_name` STRING,`revenue` DOUBLE," +
+ "`c_acctbal` DOUBLE,`n_name` STRING,`c_address` STRING,`c_phone` STRING,`c_comment` STRING"),
+ "q18" -> ("`c_name` STRING,`c_custkey` BIGINT,`o_orderkey` BIGINT," +
+ "`o_orderdate` DATE,`o_totalprice` DOUBLE,`sum(l_quantity)` DOUBLE"),
+ "q14" -> "`promo_revenue` DOUBLE",
+ "q2" -> ("`s_acctbal` DOUBLE,`s_name` STRING,`n_name` STRING," +
+ "`p_partkey` BIGINT,`p_mfgr` STRING,`s_address` STRING,`s_phone` STRING,`s_comment` STRING"),
+ "q17" -> "`avg_yearly` DOUBLE",
+ "q8" -> "`o_year` INT,`mkt_share` DOUBLE",
+ "q6" -> "`revenue` DOUBLE",
+ "q12" -> "`l_shipmode` STRING,`high_line_count` BIGINT,`low_line_count` BIGINT")
+
+ val queryToSchema_3_2: Map[String, String] = queryToUnchangedSchema ++ Map(
+ "q4" -> "`o_orderpriority` STRING,`order_count` BIGINT NOT NULL",
+ "q22" -> "`cntrycode` STRING,`numcust` BIGINT NOT NULL,`totacctbal` DOUBLE",
+ "q21" -> "`s_name` STRING,`numwait` BIGINT NOT NULL",
+ "q13" -> "`c_count` BIGINT NOT NULL,`custdist` BIGINT NOT NULL",
+ "q1" -> ("`l_returnflag` STRING,`l_linestatus` STRING,`sum_qty` DOUBLE," +
+ "`sum_base_price` DOUBLE,`sum_disc_price` DOUBLE,`sum_charge` DOUBLE," +
+ "`avg_qty` DOUBLE,`avg_price` DOUBLE,`avg_disc` DOUBLE,`count_order` BIGINT NOT NULL"),
+ "q16" -> "`p_brand` STRING,`p_type` STRING,`p_size` INT,`supplier_cnt` BIGINT NOT NULL")
+
+ val queryToSchema: Map[String, String] = queryToUnchangedSchema ++ Map(
+ "q4" -> "`o_orderpriority` STRING,`order_count` BIGINT",
+ "q22" -> "`cntrycode` STRING,`numcust` BIGINT,`totacctbal` DOUBLE",
+ "q21" -> "`s_name` STRING,`numwait` BIGINT",
+ "q13" -> "`c_count` BIGINT,`custdist` BIGINT",
+ "q1" -> ("`l_returnflag` STRING,`l_linestatus` STRING,`sum_qty` DOUBLE," +
+ "`sum_base_price` DOUBLE,`sum_disc_price` DOUBLE,`sum_charge` DOUBLE," +
+ "`avg_qty` DOUBLE,`avg_price` DOUBLE,`avg_disc` DOUBLE,`count_order` BIGINT"),
+ "q16" -> "`p_brand` STRING,`p_type` STRING,`p_size` INT,`supplier_cnt` BIGINT")
+
+ test("run query on tiny") {
+ val viewSuffix = "view";
+ val sparkConf = new SparkConf().setMaster("local[*]")
+ .set("spark.ui.enabled", "false")
+ .set("spark.sql.catalogImplementation", "in-memory")
+ .set("spark.sql.catalog.tpch", classOf[TPCHCatalog].getName)
+ withSparkSession(SparkSession.builder.config(sparkConf).getOrCreate()) { spark =>
+ spark.sql("USE tpch.tiny")
+ queries.map { queryName =>
+ val in = getClass.getClassLoader.getResourceAsStream(
+ s"tpch/$queryName.sql")
+ val queryContent: String = Source.fromInputStream(in)(Codec.UTF8).mkString
+ in.close()
+ queryName -> queryContent
+ }.foreach { case (name, sql) =>
+ try {
+ val result = spark.sql(sql).collect()
+ val schema = spark.sql(sql).schema
+ spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix")
+ val sumHashResult =
+ spark.sql(s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0)
+ // scalastyle:off
+ println(s"name=$name,schema=${schema.toDDL},sumHashResult=$sumHashResult")
+ // scalastyle:on
+ assert(sumHashResult == queryToSumHash(name))
+ if (SparkUtils.isSparkVersionEqualTo("3.3")) {
+ // The toDDL method of StructType, the return value in spark3.3
+ // is different from that in spark3.2
+ // in spark3.2 "`a` INT"
+ // in spark3.3 "a INT"
Review Comment:
another option is maitain the output schema in seprate files like `OutputSchemaTPCDSSuite` does.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2806: [KYUUBI #2805] add TPC-H queries verification
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2806:
URL: https://github.com/apache/incubator-kyuubi/pull/2806#discussion_r890735776
##########
extensions/spark/kyuubi-spark-connector-tpch/src/test/scala/org/apache/kyuubi/spark/connector/tpch/TPCHQuerySuite.scala:
##########
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.spark.connector.tpch
+
+import scala.collection.JavaConverters._
+import scala.io.{Codec, Source}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSession
+import org.apache.kyuubi.spark.connector.common.SparkUtils
+
+class TPCHQuerySuite extends KyuubiFunSuite {
+
+ val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
+
+ val queryToSumHash: Map[String, Long] = Map(
+ "q11" -> -21773379672L,
+ "q7" -> -1955579146L,
+ "q4" -> 1856406098L,
+ "q5" -> 3717321142L,
+ "q20" -> -35851308L,
+ "q3" -> -4118618460L,
+ "q19" -> -1061725826L,
+ "q9" -> 10861514367L,
+ "q15" -> -2021679095L,
+ "q10" -> -4090660469L,
+ "q22" -> 2111900859L,
+ "q18" -> 1596157524L,
+ "q21" -> 1407638530L,
+ "q14" -> 47333415L,
+ "q2" -> 2296723790L,
+ "q13" -> -1379884230L,
+ "q17" -> 42L,
+ "q1" -> -2130215201L,
+ "q8" -> 453239528L,
+ "q6" -> 2062248569L,
+ "q12" -> 2455990065L,
+ "q16" -> 326972717L)
+
+ val queryToUnchangedSchema: Map[String, String] = Map(
+ "q11" -> "`ps_partkey` BIGINT,`value` DOUBLE",
+ "q7" -> "`supp_nation` STRING,`cust_nation` STRING,`l_year` INT,`revenue` DOUBLE",
+ "q5" -> "`n_name` STRING,`revenue` DOUBLE",
+ "q20" -> "`s_name` STRING,`s_address` STRING",
+ "q3" -> "`l_orderkey` BIGINT,`revenue` DOUBLE,`o_orderdate` DATE,`o_shippriority` INT",
+ "q19" -> "`revenue` DOUBLE",
+ "q9" -> "`nation` STRING,`o_year` INT,`sum_profit` DOUBLE",
+ "q15" -> ("`s_suppkey` BIGINT,`s_name` STRING,`s_address` STRING," +
+ "`s_phone` STRING,`total_revenue` DOUBLE"),
+ "q10" -> ("`c_custkey` BIGINT,`c_name` STRING,`revenue` DOUBLE," +
+ "`c_acctbal` DOUBLE,`n_name` STRING,`c_address` STRING,`c_phone` STRING,`c_comment` STRING"),
+ "q18" -> ("`c_name` STRING,`c_custkey` BIGINT,`o_orderkey` BIGINT," +
+ "`o_orderdate` DATE,`o_totalprice` DOUBLE,`sum(l_quantity)` DOUBLE"),
+ "q14" -> "`promo_revenue` DOUBLE",
+ "q2" -> ("`s_acctbal` DOUBLE,`s_name` STRING,`n_name` STRING," +
+ "`p_partkey` BIGINT,`p_mfgr` STRING,`s_address` STRING,`s_phone` STRING,`s_comment` STRING"),
+ "q17" -> "`avg_yearly` DOUBLE",
+ "q8" -> "`o_year` INT,`mkt_share` DOUBLE",
+ "q6" -> "`revenue` DOUBLE",
+ "q12" -> "`l_shipmode` STRING,`high_line_count` BIGINT,`low_line_count` BIGINT")
+
+ val queryToSchema_3_2: Map[String, String] = queryToUnchangedSchema ++ Map(
+ "q4" -> "`o_orderpriority` STRING,`order_count` BIGINT NOT NULL",
+ "q22" -> "`cntrycode` STRING,`numcust` BIGINT NOT NULL,`totacctbal` DOUBLE",
+ "q21" -> "`s_name` STRING,`numwait` BIGINT NOT NULL",
+ "q13" -> "`c_count` BIGINT NOT NULL,`custdist` BIGINT NOT NULL",
+ "q1" -> ("`l_returnflag` STRING,`l_linestatus` STRING,`sum_qty` DOUBLE," +
+ "`sum_base_price` DOUBLE,`sum_disc_price` DOUBLE,`sum_charge` DOUBLE," +
+ "`avg_qty` DOUBLE,`avg_price` DOUBLE,`avg_disc` DOUBLE,`count_order` BIGINT NOT NULL"),
+ "q16" -> "`p_brand` STRING,`p_type` STRING,`p_size` INT,`supplier_cnt` BIGINT NOT NULL")
+
+ val queryToSchema: Map[String, String] = queryToUnchangedSchema ++ Map(
+ "q4" -> "`o_orderpriority` STRING,`order_count` BIGINT",
+ "q22" -> "`cntrycode` STRING,`numcust` BIGINT,`totacctbal` DOUBLE",
+ "q21" -> "`s_name` STRING,`numwait` BIGINT",
+ "q13" -> "`c_count` BIGINT,`custdist` BIGINT",
+ "q1" -> ("`l_returnflag` STRING,`l_linestatus` STRING,`sum_qty` DOUBLE," +
+ "`sum_base_price` DOUBLE,`sum_disc_price` DOUBLE,`sum_charge` DOUBLE," +
+ "`avg_qty` DOUBLE,`avg_price` DOUBLE,`avg_disc` DOUBLE,`count_order` BIGINT"),
+ "q16" -> "`p_brand` STRING,`p_type` STRING,`p_size` INT,`supplier_cnt` BIGINT")
+
+ test("run query on tiny") {
+ val viewSuffix = "view";
+ val sparkConf = new SparkConf().setMaster("local[*]")
+ .set("spark.ui.enabled", "false")
+ .set("spark.sql.catalogImplementation", "in-memory")
+ .set("spark.sql.catalog.tpch", classOf[TPCHCatalog].getName)
+ withSparkSession(SparkSession.builder.config(sparkConf).getOrCreate()) { spark =>
+ spark.sql("USE tpch.tiny")
+ queries.map { queryName =>
+ val in = getClass.getClassLoader.getResourceAsStream(
+ s"tpch/$queryName.sql")
+ val queryContent: String = Source.fromInputStream(in)(Codec.UTF8).mkString
+ in.close()
+ queryName -> queryContent
+ }.foreach { case (name, sql) =>
+ try {
+ val result = spark.sql(sql).collect()
+ val schema = spark.sql(sql).schema
+ spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix")
+ val sumHashResult =
+ spark.sql(s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0)
+ // scalastyle:off
+ println(s"name=$name,schema=${schema.toDDL},sumHashResult=$sumHashResult")
+ // scalastyle:on
+ assert(sumHashResult == queryToSumHash(name))
+ if (SparkUtils.isSparkVersionEqualTo("3.3")) {
+ // The toDDL method of StructType, the return value in spark3.3
+ // is different from that in spark3.2
+ // in spark3.2 "`a` INT"
+ // in spark3.3 "a INT"
Review Comment:
It's fragile to use String to compare schema, would you please try to compare `StructType` directly?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org