From 435e85f5d83694b2bacee2df16ceb015e34f438b Mon Sep 17 00:00:00 2001 From: fwang12 Date: Sun, 25 Apr 2021 18:27:05 +0800 Subject: [PATCH] [KYUUBI #603] [TEST] Refactor test name and sort the tpcds queries ### _Why are the changes needed?_ Refactor the test name to show tpcds version information and sort the test queries by query number. ### _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 - [x] [Run test](https://kyuubi.readthedocs.io/en/latest/tools/testing.html#running-tests) locally before make a pull request Closes #603 from turboFei/tpcds_refactor. Closes #603 1c8daad5 [fwang12] add accident deleted q3 2f62b650 [fwang12] [TEST] Refactor test name and sort the tpcds queries Authored-by: fwang12 Signed-off-by: Cheng Pan <379377944@qq.com> --- .../src/test/resources/tpcds-1_4/q3/q3.sql | 30 +++++++++++++++++++ .../tpcds/TPCDSOutputSchemaSuite.scala | 9 ++++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 kyuubi-main/src/test/resources/tpcds-1_4/q3/q3.sql diff --git a/kyuubi-main/src/test/resources/tpcds-1_4/q3/q3.sql b/kyuubi-main/src/test/resources/tpcds-1_4/q3/q3.sql new file mode 100755 index 000000000..924576260 --- /dev/null +++ b/kyuubi-main/src/test/resources/tpcds-1_4/q3/q3.sql @@ -0,0 +1,30 @@ +-- +-- 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. +-- + +SELECT + dt.d_year, + item.i_brand_id brand_id, + item.i_brand brand, + SUM(ss_ext_sales_price) sum_agg +FROM date_dim dt, store_sales, item +WHERE dt.d_date_sk = store_sales.ss_sold_date_sk + AND store_sales.ss_item_sk = item.i_item_sk + AND item.i_manufact_id = 128 + AND dt.d_moy = 11 +GROUP BY dt.d_year, item.i_brand, item.i_brand_id +ORDER BY dt.d_year, sum_agg DESC, brand_id +LIMIT 100 diff --git a/kyuubi-main/src/test/scala/org/apache/kyuubi/operation/tpcds/TPCDSOutputSchemaSuite.scala b/kyuubi-main/src/test/scala/org/apache/kyuubi/operation/tpcds/TPCDSOutputSchemaSuite.scala index 8fa2fb7b8..9b928ed1a 100644 --- a/kyuubi-main/src/test/scala/org/apache/kyuubi/operation/tpcds/TPCDSOutputSchemaSuite.scala +++ b/kyuubi-main/src/test/scala/org/apache/kyuubi/operation/tpcds/TPCDSOutputSchemaSuite.scala @@ -41,6 +41,7 @@ class TPCDSOutputSchemaSuite extends WithKyuubiServer with JDBCTestUtils with TP override protected def jdbcUrl: String = getJdbcUrl override def database: String = this.getClass.getSimpleName override def format: String = "hive OPTIONS(fileFormat='parquet')" + private val queryNameReg = """([a-z]+)(\d+)""".r("head", "index") override def beforeAll(): Unit = { super.beforeAll() @@ -88,6 +89,10 @@ class TPCDSOutputSchemaSuite extends WithKyuubiServer with JDBCTestUtils with TP } } + private def getQueryIndex(queryName: String): Int = queryName match { + case queryNameReg(_, index) => index.toInt + } + private def runQueries(name: String): Unit = { val queriesRoot = Thread.currentThread().getContextClassLoader.getResource(name) val queries = Files.list(Paths.get(queriesRoot.toURI)) @@ -95,10 +100,10 @@ class TPCDSOutputSchemaSuite extends WithKyuubiServer with JDBCTestUtils with TP val validQueries = queries.iterator().asScala.filter { query => query.toFile.listFiles().exists(_.getName.endsWith(".sql")) - } + }.toSeq.sortBy(q => getQueryIndex(q.getFileName.toString)) validQueries.foreach { q => - test(q.getFileName.toString) { + test(name + "-" + q.getFileName.toString) { q.toFile.listFiles().filter(_.getName.endsWith(".sql")).foreach { qf => val schemaFile = Paths.get( baseResourcePath.toFile.getAbsolutePath,