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

FelixYBW 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 76738e9afb [VL] Follow-up to #12072: pick the Parquet codec the same 
way as Spark (#13777)
76738e9afb is described below

commit 76738e9afb6a5b47ac72b8bccb396c6bb3e94d62
Author: Felix Loesing <[email protected]>
AuthorDate: Tue Nov 24 18:55:10 2026 -0800

    [VL] Follow-up to #12072: pick the Parquet codec the same way as Spark 
(#13777)
    
    * Prioritize Spark SQL parquet compression config over hadoop
    
    * scala2.13 fix
---
 .../backendsapi/velox/VeloxTransformerApi.scala    |  6 ++++-
 .../sql/execution/VeloxParquetWriteSuite.scala     | 27 ++++++++++++++++------
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git 
a/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxTransformerApi.scala
 
b/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxTransformerApi.scala
index 5fabab93a6..18459d9686 100644
--- 
a/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxTransformerApi.scala
+++ 
b/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxTransformerApi.scala
@@ -201,7 +201,11 @@ class VeloxTransformerApi extends TransformerApi with 
Logging {
           GlutenFormatFactory(shortName)
             .nativeConf(
               writeOptions,
-              WriteFilesExecTransformer.getCompressionCodec(writeOptions))
+              // Match Spark's Parquet write precedence. Hadoop configuration 
is still passed
+              // through for filesystem and writer settings, but inherited 
Hadoop properties must
+              // not be treated as explicit data source options.
+              
WriteFilesExecTransformer.getCompressionCodec(write.caseInsensitiveOptions)
+            )
         packPBMessage(
           ConfigMap
             .newBuilder()
diff --git 
a/backends-velox/src/test/scala/org/apache/spark/sql/execution/VeloxParquetWriteSuite.scala
 
b/backends-velox/src/test/scala/org/apache/spark/sql/execution/VeloxParquetWriteSuite.scala
index 86058e122b..02943e79fd 100644
--- 
a/backends-velox/src/test/scala/org/apache/spark/sql/execution/VeloxParquetWriteSuite.scala
+++ 
b/backends-velox/src/test/scala/org/apache/spark/sql/execution/VeloxParquetWriteSuite.scala
@@ -26,6 +26,7 @@ import org.apache.spark.util.Utils
 
 import org.apache.hadoop.fs.Path
 import org.apache.parquet.hadoop.ParquetFileReader
+import org.apache.parquet.hadoop.metadata.{ColumnChunkMetaData, 
CompressionCodecName}
 import org.apache.parquet.hadoop.util.HadoopInputFile
 import org.apache.parquet.schema.PrimitiveType
 
@@ -391,26 +392,27 @@ class VeloxParquetWriteHadoopConfSuite extends 
VeloxWholeStageTransformerSuite w
     super.sparkConf
       .set(GlutenConfig.NATIVE_WRITER_ENABLED.key, "true")
       .set(s"spark.hadoop.parquet.enable.dictionary", "false")
+      .set("spark.hadoop.parquet.compression", "gzip")
   }
 
   private val dictionaryEncodingNames = Set("PLAIN_DICTIONARY", 
"RLE_DICTIONARY")
 
-  private def parquetColumnEncodings(dir: File): Seq[Set[String]] = {
+  private def parquetColumnChunks(dir: File): Seq[ColumnChunkMetaData] = {
     val parquetFiles = dir.list((_, name) => name.contains("parquet"))
     assert(parquetFiles.nonEmpty)
-    parquetFiles.flatMap {
+    parquetFiles.toSeq.flatMap {
       file =>
         val path = new Path(dir.getAbsolutePath, file)
         val in = HadoopInputFile.fromPath(path, 
spark.sessionState.newHadoopConf())
         Utils.tryWithResource(ParquetFileReader.open(in)) {
-          reader =>
-            reader.getFooter.getBlocks.asScala.flatMap {
-              block => 
block.getColumns.asScala.map(_.getEncodings.asScala.map(_.name()).toSet)
-            }
+          reader => 
reader.getFooter.getBlocks.asScala.flatMap(_.getColumns.asScala)
         }
-    }.toSeq
+    }
   }
 
+  private def parquetColumnEncodings(dir: File): Seq[Set[String]] =
+    parquetColumnChunks(dir).map(_.getEncodings.asScala.map(_.name()).toSet)
+
   test("native writer should respect parquet dictionary config from 
spark.hadoop config") {
     spark
       .range(0, 20000, 1, 1)
@@ -430,4 +432,15 @@ class VeloxParquetWriteHadoopConfSuite extends 
VeloxWholeStageTransformerSuite w
         
assert(!columnEncodings.exists(_.exists(dictionaryEncodingNames.contains)))
     }
   }
+
+  test("native writer should prefer Spark SQL codec over 
spark.hadoop.parquet.compression") {
+    withSQLConf(SQLConf.PARQUET_COMPRESSION.key -> "zstd") {
+      withTempPath {
+        dir =>
+          checkNativeWrite(
+            s"INSERT OVERWRITE DIRECTORY '${dir.getCanonicalPath}' USING 
PARQUET SELECT 1 AS id")
+          assert(parquetColumnChunks(dir).map(_.getCodec).toSet == 
Set(CompressionCodecName.ZSTD))
+      }
+    }
+  }
 }


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

Reply via email to