stefankandic commented on code in PR #45739: URL: https://github.com/apache/spark/pull/45739#discussion_r1551960665
########## sql/core/src/test/scala/org/apache/spark/sql/TPCDSCollationQueryTestSuite.scala: ########## @@ -0,0 +1,214 @@ +/* + * 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.spark.sql + +import java.nio.file.{Files, Paths} +import java.util.Locale + +import org.apache.spark.{SparkConf, SparkContext} +import org.apache.spark.sql.catalyst.util.resourceToString +import org.apache.spark.sql.internal.SQLConf +import org.apache.spark.sql.test.TestSparkSession +import org.apache.spark.tags.ExtendedSQLTest +import org.apache.spark.util.Utils + +@ExtendedSQLTest +class TPCDSCollationQueryTestSuite extends QueryTest with TPCDSBase with SQLQueryTestHelper { + + private val tpcdsDataPath = sys.env.get("SPARK_TPCDS_DATA") + + // To make output results deterministic + override protected def sparkConf: SparkConf = super.sparkConf + .set(SQLConf.SHUFFLE_PARTITIONS.key, "1") + + protected override def createSparkSession: TestSparkSession = { + new TestSparkSession(new SparkContext("local[1]", this.getClass.getSimpleName, sparkConf)) + } + + if (tpcdsDataPath.nonEmpty) { + val nonExistentTables = tableColumns.keys.filterNot { tableName => + Files.exists(Paths.get(s"${tpcdsDataPath.get}/$tableName")) + } + if (nonExistentTables.nonEmpty) { + fail(s"Non-existent TPCDS table paths found in ${tpcdsDataPath.get}: " + + nonExistentTables.mkString(", ")) + } + } + + private def withDB[T](dbName: String)(fun: => T): T = { + Utils.tryWithSafeFinally({ + spark.sql(s"USE `$dbName`") + fun + }) { + spark.sql("USE DEFAULT") + } + } + + abstract class CollationCheck(val dbName: String, + val collation: String, Review Comment: fix indentation here and below for constructor parameters -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
