MaxGekk commented on code in PR #47620:
URL: https://github.com/apache/spark/pull/47620#discussion_r1711362004
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationStringExpressionsSuite.scala:
##########
@@ -17,135 +17,130 @@
package org.apache.spark.sql
-import org.apache.spark.{SparkConf, SparkIllegalArgumentException}
-import org.apache.spark.sql.catalyst.expressions.{ExpressionEvalHelper,
Literal, StringTrim, StringTrimLeft, StringTrimRight}
-import org.apache.spark.sql.catalyst.util.CollationFactory
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SharedSparkSession
-import org.apache.spark.sql.types.{ArrayType, BinaryType, BooleanType,
DataType, IntegerType, StringType}
+import org.apache.spark.sql.types._
// scalastyle:off nonascii
class CollationStringExpressionsSuite
- extends QueryTest
- with SharedSparkSession
- with ExpressionEvalHelper {
+ extends QueryTest
+ with SharedSparkSession
+ with ExpressionEvalHelper {
- test("Support ConcatWs string expression with collation") {
- // Supported collations
- case class ConcatWsTestCase[R](s: String, a: Array[String], c: String,
result: R)
+ test("Support `ConcatWs` string expression with collation") {
+ case class ConcatWsTestCase[R](
+ sep: String,
+ arrayStr: Array[String],
+ collation: String,
+ result: R)
val testCases = Seq(
ConcatWsTestCase(" ", Array("Spark", "SQL"), "UTF8_BINARY", "Spark SQL"),
ConcatWsTestCase(" ", Array("Spark", "SQL"), "UTF8_LCASE", "Spark SQL"),
ConcatWsTestCase(" ", Array("Spark", "SQL"), "UNICODE", "Spark SQL"),
ConcatWsTestCase(" ", Array("Spark", "SQL"), "UNICODE_CI", "Spark SQL")
)
testCases.foreach(t => {
- val arrCollated = t.a.map(s => s"collate('$s', '${t.c}')").mkString(", ")
- var query = s"SELECT concat_ws(collate('${t.s}', '${t.c}'),
$arrCollated)"
- // Result & data type
- checkAnswer(sql(query), Row(t.result))
- assert(sql(query).schema.fields.head.dataType.sameType(StringType(t.c)))
- // Implicit casting
- val arr = t.a.map(s => s"'$s'").mkString(", ")
- query = s"SELECT concat_ws(collate('${t.s}', '${t.c}'), $arr)"
- checkAnswer(sql(query), Row(t.result))
- assert(sql(query).schema.fields.head.dataType.sameType(StringType(t.c)))
- query = s"SELECT concat_ws('${t.s}', $arrCollated)"
- checkAnswer(sql(query), Row(t.result))
- assert(sql(query).schema.fields.head.dataType.sameType(StringType(t.c)))
+ // Unit test.
Review Comment:
How about to split the expressions and end-to-end tests to 2 different
suites like `StringExpressionsSuite` and `StringFunctionsSuite` (could be
`CollationStringE2ESuite`). The expression test suite might cover more cases
but e2e test suite should check just some cases.
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationStringExpressionsSuite.scala:
##########
@@ -17,135 +17,130 @@
package org.apache.spark.sql
-import org.apache.spark.{SparkConf, SparkIllegalArgumentException}
-import org.apache.spark.sql.catalyst.expressions.{ExpressionEvalHelper,
Literal, StringTrim, StringTrimLeft, StringTrimRight}
-import org.apache.spark.sql.catalyst.util.CollationFactory
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SharedSparkSession
-import org.apache.spark.sql.types.{ArrayType, BinaryType, BooleanType,
DataType, IntegerType, StringType}
+import org.apache.spark.sql.types._
// scalastyle:off nonascii
class CollationStringExpressionsSuite
- extends QueryTest
- with SharedSparkSession
- with ExpressionEvalHelper {
+ extends QueryTest
Review Comment:
Why did you add the indents. The style guide says about 2 spaces, see
https://github.com/databricks/scala-style-guide?tab=readme-ov-file#spacing-and-indentation.
Does scala style check complain about 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: [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]