MaxGekk commented on code in PR #48608:
URL: https://github.com/apache/spark/pull/48608#discussion_r1814671979


##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSQLExpressionsSuite.scala:
##########
@@ -2435,829 +2448,878 @@ class CollationSQLExpressionsSuite
   }
 
   test("min_by supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT min_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 
20) AS tab(x, y);"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row("a")
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT min_by(x, y) FROM VALUES ('a', 10), ('b', 50), 
('c', 20) AS tab(x, y);"
+      withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
+        checkAnswer(
+          sql(query),
+          Seq(
+            Row("a")
+          )
         )
-      )
-      // check result row data type
-      val dataType = StringType(collation)
-      assert(sql(query).schema.head.dataType == dataType)
-    }
+        // check result row data type
+        val dataType = StringType(collation)
+        assert(sql(query).schema.head.dataType == dataType)
+      }
+    })
   }
 
   test("max_by supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT max_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 
20) AS tab(x, y);"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row("b")
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT max_by(x, y) FROM VALUES ('a', 10), ('b', 50), 
('c', 20) AS tab(x, y);"
+      withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
+        checkAnswer(
+          sql(query),
+          Seq(
+            Row("b")
+          )
         )
-      )
-      // check result row data type
-      val dataType = StringType(collation)
-      assert(sql(query).schema.head.dataType == dataType)
-    }
+        // check result row data type
+        val dataType = StringType(collation)
+        assert(sql(query).schema.head.dataType == dataType)
+      }
+    })
   }
 
   test("array supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT array('a', 'b', 'c');"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row(Seq("a", "b", "c"))
+    testAdditionalCollations.foreach(collation => {

Review Comment:
   nit. Here and below:
   ```suggestion
       testAdditionalCollations.foreach { collation =>
   ```



##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSQLExpressionsSuite.scala:
##########
@@ -2435,829 +2448,878 @@ class CollationSQLExpressionsSuite
   }
 
   test("min_by supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT min_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 
20) AS tab(x, y);"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row("a")
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT min_by(x, y) FROM VALUES ('a', 10), ('b', 50), 
('c', 20) AS tab(x, y);"
+      withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
+        checkAnswer(
+          sql(query),
+          Seq(
+            Row("a")
+          )
         )
-      )
-      // check result row data type
-      val dataType = StringType(collation)
-      assert(sql(query).schema.head.dataType == dataType)
-    }
+        // check result row data type
+        val dataType = StringType(collation)
+        assert(sql(query).schema.head.dataType == dataType)
+      }
+    })
   }
 
   test("max_by supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT max_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 
20) AS tab(x, y);"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row("b")
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT max_by(x, y) FROM VALUES ('a', 10), ('b', 50), 
('c', 20) AS tab(x, y);"
+      withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
+        checkAnswer(
+          sql(query),
+          Seq(
+            Row("b")
+          )
         )
-      )
-      // check result row data type
-      val dataType = StringType(collation)
-      assert(sql(query).schema.head.dataType == dataType)
-    }
+        // check result row data type
+        val dataType = StringType(collation)
+        assert(sql(query).schema.head.dataType == dataType)
+      }
+    })
   }
 
   test("array supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT array('a', 'b', 'c');"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row(Seq("a", "b", "c"))
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT array('a', 'b', 'c');"

Review Comment:
   s" is not needed. Please, remove it.



##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSQLExpressionsSuite.scala:
##########
@@ -2435,829 +2448,878 @@ class CollationSQLExpressionsSuite
   }
 
   test("min_by supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT min_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 
20) AS tab(x, y);"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row("a")
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT min_by(x, y) FROM VALUES ('a', 10), ('b', 50), 
('c', 20) AS tab(x, y);"
+      withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
+        checkAnswer(
+          sql(query),
+          Seq(
+            Row("a")
+          )
         )
-      )
-      // check result row data type
-      val dataType = StringType(collation)
-      assert(sql(query).schema.head.dataType == dataType)
-    }
+        // check result row data type
+        val dataType = StringType(collation)
+        assert(sql(query).schema.head.dataType == dataType)
+      }
+    })
   }
 
   test("max_by supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT max_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 
20) AS tab(x, y);"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row("b")
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT max_by(x, y) FROM VALUES ('a', 10), ('b', 50), 
('c', 20) AS tab(x, y);"
+      withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
+        checkAnswer(
+          sql(query),
+          Seq(
+            Row("b")
+          )
         )
-      )
-      // check result row data type
-      val dataType = StringType(collation)
-      assert(sql(query).schema.head.dataType == dataType)
-    }
+        // check result row data type
+        val dataType = StringType(collation)
+        assert(sql(query).schema.head.dataType == dataType)
+      }
+    })
   }
 
   test("array supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT array('a', 'b', 'c');"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row(Seq("a", "b", "c"))
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT array('a', 'b', 'c');"
+      withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
+        checkAnswer(
+          sql(query),
+          Seq(
+            Row(Seq("a", "b", "c"))
+          )
         )
-      )
-      // check result row data type
-      val dataType = ArrayType(StringType(collation), false)
-      assert(sql(query).schema.head.dataType == dataType)
-    }
+        // check result row data type
+        val dataType = ArrayType(StringType(collation), false)
+        assert(sql(query).schema.head.dataType == dataType)
+      }
+    })
   }
 
   test("array_agg supports collation") {

Review Comment:
   Those all tests are similar. Let's rewrite in the way:
   ```scala
       testAdditionalCollations.foreach { collation =>
         Seq(
           "SELECT array('a', 'b', 'c')" -> Seq(Row(Seq("a", "b", "c"))),
           "SELECT array_agg(col) FROM VALUES ('a'), ('b'), ('c') AS tab(col)" 
->
             Seq(Row(Seq("a", "b", "c")))
         ).foreach { case (query, result) =>
           withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
             checkAnswer(sql(query), result)
             // check result row data type
             val dataType = ArrayType(StringType(collation), false)
             assert(sql(query).schema.head.dataType == dataType)
           }
         }
       }
   ```



##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSQLExpressionsSuite.scala:
##########
@@ -2435,829 +2448,878 @@ class CollationSQLExpressionsSuite
   }
 
   test("min_by supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT min_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 
20) AS tab(x, y);"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row("a")
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT min_by(x, y) FROM VALUES ('a', 10), ('b', 50), 
('c', 20) AS tab(x, y);"
+      withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
+        checkAnswer(
+          sql(query),
+          Seq(
+            Row("a")
+          )
         )
-      )
-      // check result row data type
-      val dataType = StringType(collation)
-      assert(sql(query).schema.head.dataType == dataType)
-    }
+        // check result row data type
+        val dataType = StringType(collation)
+        assert(sql(query).schema.head.dataType == dataType)
+      }
+    })
   }
 
   test("max_by supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT max_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 
20) AS tab(x, y);"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row("b")
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT max_by(x, y) FROM VALUES ('a', 10), ('b', 50), 
('c', 20) AS tab(x, y);"
+      withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
+        checkAnswer(
+          sql(query),
+          Seq(
+            Row("b")
+          )
         )
-      )
-      // check result row data type
-      val dataType = StringType(collation)
-      assert(sql(query).schema.head.dataType == dataType)
-    }
+        // check result row data type
+        val dataType = StringType(collation)
+        assert(sql(query).schema.head.dataType == dataType)
+      }
+    })
   }
 
   test("array supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT array('a', 'b', 'c');"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row(Seq("a", "b", "c"))
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT array('a', 'b', 'c');"
+      withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
+        checkAnswer(
+          sql(query),
+          Seq(
+            Row(Seq("a", "b", "c"))
+          )
         )
-      )
-      // check result row data type
-      val dataType = ArrayType(StringType(collation), false)
-      assert(sql(query).schema.head.dataType == dataType)
-    }
+        // check result row data type
+        val dataType = ArrayType(StringType(collation), false)
+        assert(sql(query).schema.head.dataType == dataType)
+      }
+    })
   }
 
   test("array_agg supports collation") {
-    val collation = "UNICODE"
-    val query = s"SELECT array_agg(col) FROM VALUES ('a'), ('b'), ('c') AS 
tab(col);"
-    withSQLConf(SqlApiConf.DEFAULT_COLLATION -> collation) {
-      checkAnswer(
-        sql(query),
-        Seq(
-          Row(Seq("a", "b", "c"))
+    testAdditionalCollations.foreach(collation => {
+      val query = s"SELECT array_agg(col) FROM VALUES ('a'), ('b'), ('c') AS 
tab(col);"

Review Comment:
   Is s" needed?



-- 
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]

Reply via email to