This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new c362d500acba [SPARK-49775][SQL][TESTS] Make tests of 
`INVALID_PARAMETER_VALUE.CHARSET` deterministic
c362d500acba is described below

commit c362d500acba5bcf476a2a91ac9b7441ba1e7e2d
Author: Ruifeng Zheng <[email protected]>
AuthorDate: Wed Sep 25 19:35:33 2024 +0900

    [SPARK-49775][SQL][TESTS] Make tests of `INVALID_PARAMETER_VALUE.CHARSET` 
deterministic
    
    ### What changes were proposed in this pull request?
    Make tests of `INVALID_PARAMETER_VALUE.CHARSET` deterministic
    
    ### Why are the changes needed?
    `VALID_CHARSETS` is a Set, so `VALID_CHARSETS.mkString(", ")` is 
non-deterministic, and cause failures in different testing environments, e.g.
    ```
            org.scalatest.exceptions.TestFailedException: 
ansi/string-functions.sql
    Expected "...sets" : "UTF-16LE, U[TF-8, UTF-32, UTF-16BE, UTF-16, US-ASCII, 
ISO-8859-1]",
        "functionName...", but got "...sets" : "UTF-16LE, U[S-ASCII, 
ISO-8859-1, UTF-8, UTF-32, UTF-16BE, UTF-16]",
        "functionName..." Result did not match for query #93
    select encode('hello', 'WINDOWS-1252')
          at 
org.scalatest.Assertions.newAssertionFailedException(Assertions.scala:472)
          at 
org.scalatest.Assertions.newAssertionFailedException$(Assertions.scala:471)
          at 
org.scalatest.funsuite.AnyFunSuite.newAssertionFailedException(AnyFunSuite.scala:1564)
          at org.scalatest.Assertions.assertResult(Assertions.scala:847)
          at org.scalatest.Assertions.assertResult$(Assertions.scala:842)
          at 
org.scalatest.funsuite.AnyFunSuite.assertResult(AnyFunSuite.scala:1564)
    
    ```
    
    ### Does this PR introduce _any_ user-facing change?
    No, test only
    
    ### How was this patch tested?
    updated tests
    
    ### Was this patch authored or co-authored using generative AI tooling?
    no
    
    Closes #48235 from zhengruifeng/sql_test_sort_charset.
    
    Authored-by: Ruifeng Zheng <[email protected]>
    Signed-off-by: Hyukjin Kwon <[email protected]>
---
 .../apache/spark/sql/catalyst/util/CharsetProvider.scala |  2 +-
 .../sql-tests/results/ansi/string-functions.sql.out      | 16 ++++++++--------
 .../resources/sql-tests/results/string-functions.sql.out | 16 ++++++++--------
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/CharsetProvider.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/CharsetProvider.scala
index 0e7fca24e137..d85673f2ce81 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/CharsetProvider.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/CharsetProvider.scala
@@ -24,7 +24,7 @@
 private[sql] object CharsetProvider {
 
   final lazy val VALID_CHARSETS =
-    Set("us-ascii", "iso-8859-1", "utf-8", "utf-16be", "utf-16le", "utf-16", 
"utf-32")
+    Array("us-ascii", "iso-8859-1", "utf-8", "utf-16be", "utf-16le", "utf-16", 
"utf-32").sorted
 
   def forName(
       charset: String,
diff --git 
a/sql/core/src/test/resources/sql-tests/results/ansi/string-functions.sql.out 
b/sql/core/src/test/resources/sql-tests/results/ansi/string-functions.sql.out
index cf1bce3c0e50..706673606625 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/ansi/string-functions.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/ansi/string-functions.sql.out
@@ -842,7 +842,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "WINDOWS-1252",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`encode`",
     "parameter" : "`charset`"
   }
@@ -860,7 +860,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "WINDOWS-1252",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`encode`",
     "parameter" : "`charset`"
   }
@@ -878,7 +878,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "Windows-xxx",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`encode`",
     "parameter" : "`charset`"
   }
@@ -896,7 +896,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "Windows-xxx",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`encode`",
     "parameter" : "`charset`"
   }
@@ -1140,7 +1140,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "Windows-xxx",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`decode`",
     "parameter" : "`charset`"
   }
@@ -1158,7 +1158,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "Windows-xxx",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`decode`",
     "parameter" : "`charset`"
   }
@@ -1208,7 +1208,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "WINDOWS-1252",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`decode`",
     "parameter" : "`charset`"
   }
@@ -1226,7 +1226,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "WINDOWS-1252",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`decode`",
     "parameter" : "`charset`"
   }
diff --git 
a/sql/core/src/test/resources/sql-tests/results/string-functions.sql.out 
b/sql/core/src/test/resources/sql-tests/results/string-functions.sql.out
index 14d7b31f8c63..3f9f24f817f2 100644
--- a/sql/core/src/test/resources/sql-tests/results/string-functions.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/string-functions.sql.out
@@ -778,7 +778,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "WINDOWS-1252",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`encode`",
     "parameter" : "`charset`"
   }
@@ -796,7 +796,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "WINDOWS-1252",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`encode`",
     "parameter" : "`charset`"
   }
@@ -814,7 +814,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "Windows-xxx",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`encode`",
     "parameter" : "`charset`"
   }
@@ -832,7 +832,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "Windows-xxx",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`encode`",
     "parameter" : "`charset`"
   }
@@ -1076,7 +1076,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "Windows-xxx",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`decode`",
     "parameter" : "`charset`"
   }
@@ -1094,7 +1094,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "Windows-xxx",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`decode`",
     "parameter" : "`charset`"
   }
@@ -1144,7 +1144,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "WINDOWS-1252",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`decode`",
     "parameter" : "`charset`"
   }
@@ -1162,7 +1162,7 @@ org.apache.spark.SparkIllegalArgumentException
   "sqlState" : "22023",
   "messageParameters" : {
     "charset" : "WINDOWS-1252",
-    "charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, 
us-ascii",
+    "charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, 
utf-8",
     "functionName" : "`decode`",
     "parameter" : "`charset`"
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to