jackylee-ch commented on code in PR #8501:
URL: https://github.com/apache/incubator-gluten/pull/8501#discussion_r1913131203
##########
shims/spark32/src/main/scala/org/apache/gluten/sql/shims/spark32/Spark32Shims.scala:
##########
@@ -296,4 +300,19 @@ class Spark32Shims extends SparkShims {
override def unsetOperatorId(plan: QueryPlan[_]): Unit = {
plan.unsetTagValue(QueryPlan.OP_ID_TAG)
}
+
+ override def isParquetFileEncrypted(
+ fileStatus: LocatedFileStatus,
+ conf: Configuration): Boolean = {
+ try {
+ ParquetFileReader.readFooter(new Configuration(),
fileStatus.getPath).toString
+ false
+ } catch {
+ case e: Exception if ExceptionUtils.hasCause(e,
classOf[ParquetCryptoRuntimeException]) =>
Review Comment:
Why use `ExceptionUtils.hasCause` instead of `case _:
ParquetCryptoRuntimeException` ?
##########
shims/spark33/src/main/scala/org/apache/gluten/sql/shims/spark33/Spark33Shims.scala:
##########
@@ -377,4 +381,19 @@ class Spark33Shims extends SparkShims {
override def unsetOperatorId(plan: QueryPlan[_]): Unit = {
plan.unsetTagValue(QueryPlan.OP_ID_TAG)
}
+ override def isParquetFileEncrypted(
+ fileStatus: LocatedFileStatus,
+ conf: Configuration): Boolean = {
+ try {
+ ParquetFileReader.readFooter(new Configuration(),
fileStatus.getPath).toString
+ false
+ } catch {
+ case e: Exception if ExceptionUtils.hasCause(e,
classOf[ParquetCryptoRuntimeException]) =>
Review Comment:
ditto
##########
gluten-ut/spark33/src/test/scala/org/apache/spark/sql/gluten/ParquetEncryptionDetectionSuite.scala:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.sql.gluten
+
+import org.apache.gluten.sql.shims.SparkShimLoader
+
+import org.apache.hadoop.conf.Configuration
+import org.apache.hadoop.fs.{FileSystem, LocatedFileStatus, Path}
+import org.apache.parquet.crypto.{ColumnEncryptionProperties,
FileEncryptionProperties}
+import org.apache.parquet.example.data.simple.SimpleGroup
+import org.apache.parquet.hadoop.example.ExampleParquetWriter
+import org.apache.parquet.hadoop.metadata.ColumnPath
+import org.apache.parquet.schema.{MessageType, PrimitiveType, Type, Types}
+import org.junit.Assert._
+import org.scalatest.funsuite.AnyFunSuite
+
+import java.io.File
+import java.nio.charset.StandardCharsets
+import java.util.Base64
+
+import scala.collection.JavaConverters._
+
+/**
+ * This suite attempt to test parquet encryption for fallback of scan
operator. Will check the
+ * following:
+ * 1. Plain Parquet File:
+ * - Writes a Parquet file with no encryption.
+ * - Asserts that parquet is not encrypted
+ *
+ * 2. Encrypted Parquet File (with encrypted footer):
+ * - Writes a Parquet file with column-level encryption and an encrypted
footer.
+ * - Asserts that the file is encrypted.
+ *
+ * 3. Encrypted Parquet File (with plaintext footer):
+ * - Writes a Parquet file with column-level encryption but a plaintext
(unencrypted) footer.
+ * - Ensures the file is still detected as encrypted despite the plaintext
footer.
+ */
+
+class ParquetEncryptionDetectionSuite extends AnyFunSuite {
Review Comment:
This test can be moved to backends-velox and tested with
`testWithSpecifiedSparkVersion`.
And also, we can use existing parquet files instead of writing new ones each
time.
--
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]