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

rui-mo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 612282cb81 [CORE] Normalize the case of spark.sql.mapKeyDedupPolicy 
and spark.io… (#13613)
612282cb81 is described below

commit 612282cb813514292b9915da39eed0705bf5bfa3
Author: Pedrum Jalali <[email protected]>
AuthorDate: Thu Nov 19 16:39:41 2026 -0800

    [CORE] Normalize the case of spark.sql.mapKeyDedupPolicy and spark.io… 
(#13613)
    
    Co-authored-by: Pedrum Jalali <[email protected]>
---
 .../apache/gluten/execution/MiscOperatorSuite.scala |  8 ++++++++
 .../functions/ScalarFunctionsValidateSuite.scala    | 21 +++++++++++++++++++++
 .../org/apache/gluten/config/GlutenConfig.scala     | 17 +++++++++++++++--
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git 
a/backends-velox/src/test/scala/org/apache/gluten/execution/MiscOperatorSuite.scala
 
b/backends-velox/src/test/scala/org/apache/gluten/execution/MiscOperatorSuite.scala
index d7a11c315a..6fbca37257 100644
--- 
a/backends-velox/src/test/scala/org/apache/gluten/execution/MiscOperatorSuite.scala
+++ 
b/backends-velox/src/test/scala/org/apache/gluten/execution/MiscOperatorSuite.scala
@@ -2691,6 +2691,14 @@ class MiscOperatorSuite extends 
VeloxWholeStageTransformerSuite with AdaptiveSpa
     }
   }
 
+  test("native aggregation with spark.io.compression.codec set in upper case") 
{
+    withSQLConf("spark.io.compression.codec" -> "ZSTD") {
+      runQueryAndCompare("select l_returnflag, count(*) from lineitem group by 
l_returnflag") {
+        checkGlutenPlan[HashAggregateExecTransformer]
+      }
+    }
+  }
+
   test("exchange reuse with CTE lateral view explode") {
     // This test verifies the fix for Generate pre-project canonicalization.
     // When explode(split(col)) is used, a pre-project is inserted to compute 
the
diff --git 
a/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala
 
b/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala
index ea114f0a04..294ea6e611 100644
--- 
a/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala
+++ 
b/backends-velox/src/test/scala/org/apache/gluten/functions/ScalarFunctionsValidateSuite.scala
@@ -2097,4 +2097,25 @@ class ScalarFunctionsValidateSuite extends 
FunctionsValidateSuite {
         }
     }
   }
+
+  test("str_to_map with MAP_KEY_DEDUP_POLICY set in lower case") {
+    withTempPath {
+      path =>
+        Seq("a:1,b:2,a:3")
+          .toDF("s")
+          .write
+          .parquet(path.getCanonicalPath)
+
+        
spark.read.parquet(path.getCanonicalPath).createOrReplaceTempView("str_to_map_tbl")
+
+        withSQLConf(SQLConf.MAP_KEY_DEDUP_POLICY.key -> "exception") {
+          val df = sql("SELECT str_to_map(s, ',', ':') FROM str_to_map_tbl")
+          checkGlutenPlan[ProjectExecTransformer](df)
+          val e = intercept[SparkException] {
+            df.collect()
+          }
+          assert(e.getMessage.contains("Duplicate keys are not allowed"))
+        }
+    }
+  }
 }
diff --git 
a/gluten-substrait/src/main/scala/org/apache/gluten/config/GlutenConfig.scala 
b/gluten-substrait/src/main/scala/org/apache/gluten/config/GlutenConfig.scala
index 70501f3256..4620afef59 100644
--- 
a/gluten-substrait/src/main/scala/org/apache/gluten/config/GlutenConfig.scala
+++ 
b/gluten-substrait/src/main/scala/org/apache/gluten/config/GlutenConfig.scala
@@ -498,6 +498,7 @@ object GlutenConfig extends ConfigRegistry {
   val SPARK_SHUFFLE_SPILL_DISK_WRITE_BUFFER_SIZE = 
"spark.shuffle.spill.diskWriteBufferSize"
   val SPARK_SHUFFLE_SPILL_COMPRESS = "spark.shuffle.spill.compress"
   val SPARK_SHUFFLE_SPILL_COMPRESS_DEFAULT: Boolean = true
+  val SPARK_IO_COMPRESSION_CODEC = "spark.io.compression.codec"
   val SPARK_MAX_BROADCAST_TABLE_SIZE = "spark.sql.maxBroadcastTableSize"
 
   def get: GlutenConfig = {
@@ -522,7 +523,6 @@ object GlutenConfig extends ConfigRegistry {
     SQLConf.RUNTIME_BLOOM_FILTER_NUM_BITS.key,
     SQLConf.RUNTIME_BLOOM_FILTER_MAX_NUM_BITS.key,
     SQLConf.RUNTIME_BLOOM_FILTER_MAX_NUM_ITEMS.key,
-    "spark.io.compression.codec",
     "spark.sql.decimalOperations.allowPrecisionLoss",
     "spark.sql.legacy.parquet.returnNullStructIfAllFieldsMissing",
     // s3 config
@@ -591,7 +591,6 @@ object GlutenConfig extends ConfigRegistry {
         GLUTEN_COLUMNAR_TO_ROW_MEM_THRESHOLD.key,
         GLUTEN_COLUMNAR_TO_ROW_MEM_THRESHOLD.defaultValue.get.toString),
       (SPARK_SHUFFLE_SPILL_COMPRESS, 
SPARK_SHUFFLE_SPILL_COMPRESS_DEFAULT.toString),
-      (SQLConf.MAP_KEY_DEDUP_POLICY.key, 
SQLConf.MAP_KEY_DEDUP_POLICY.defaultValueString),
       (SQLConf.SESSION_LOCAL_TIMEZONE.key, 
SQLConf.SESSION_LOCAL_TIMEZONE.defaultValueString),
       (SQLConf.ANSI_ENABLED.key, SQLConf.ANSI_ENABLED.defaultValueString)
     ).foreach { case (k, defaultValue) => nativeConfMap.put(k, 
conf.getOrElse(k, defaultValue)) }
@@ -613,6 +612,20 @@ object GlutenConfig extends ConfigRegistry {
           nativeConfMap
             .put(SQLConf.LEGACY_TIME_PARSER_POLICY.key, 
v.toUpperCase(Locale.ROOT)))
 
+    // `conf` holds raw strings, so parse the policy with Spark's converter to 
give native code
+    // the same value as `SQLConf.getConf`.
+    val rawMapKeyDedupPolicy = conf.getOrElse(
+      SQLConf.MAP_KEY_DEDUP_POLICY.key,
+      SQLConf.MAP_KEY_DEDUP_POLICY.defaultValueString)
+    nativeConfMap.put(
+      SQLConf.MAP_KEY_DEDUP_POLICY.key,
+      
SQLConf.MAP_KEY_DEDUP_POLICY.valueConverter(rawMapKeyDedupPolicy).toString)
+
+    // Spark lowercases the codec name before using it, so give native code 
the same value.
+    conf
+      .get(SPARK_IO_COMPRESSION_CODEC)
+      .foreach(v => nativeConfMap.put(SPARK_IO_COMPRESSION_CODEC, 
v.toLowerCase(Locale.ROOT)))
+
     val confPrefixSession = prefixSessionOf(backendName)
     val confPrefix = prefixOf(backendName)
     // Column mapping mode is passed to Velox through scan splits, not through


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

Reply via email to