Kontinuation commented on code in PR #1817:
URL: https://github.com/apache/datafusion-comet/pull/1817#discussion_r2117529719


##########
spark/src/test/scala/org/apache/comet/parquet/ParquetReadFromS3Suite.scala:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.comet.parquet
+
+import java.net.URI
+
+import scala.util.Try
+
+import org.testcontainers.containers.MinIOContainer
+import org.testcontainers.utility.DockerImageName
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.CometTestBase
+import org.apache.spark.sql.SaveMode
+import org.apache.spark.sql.comet.CometNativeScanExec
+import org.apache.spark.sql.comet.CometScanExec
+import org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanHelper
+import org.apache.spark.sql.functions.{col, sum}
+
+import org.apache.comet.CometConf.SCAN_NATIVE_ICEBERG_COMPAT
+
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
+import software.amazon.awssdk.services.s3.S3Client
+import software.amazon.awssdk.services.s3.model.CreateBucketRequest
+import software.amazon.awssdk.services.s3.model.HeadBucketRequest
+
+class ParquetReadFromS3Suite extends CometTestBase with 
AdaptiveSparkPlanHelper {
+
+  private var minioContainer: MinIOContainer = _
+  private val userName = "minio-test-user"
+  private val password = "minio-test-password"
+  private val testBucketName = "test-bucket"
+
+  override def beforeAll(): Unit = {
+    // Start MinIO container
+    minioContainer = new 
MinIOContainer(DockerImageName.parse("minio/minio:latest"))
+      .withUserName(userName)
+      .withPassword(password)
+    minioContainer.start()
+    createBucketIfNotExists(testBucketName)
+
+    // Initialize Spark session
+    super.beforeAll()
+  }
+
+  override def afterAll(): Unit = {
+    super.afterAll()
+    if (minioContainer != null) {
+      minioContainer.stop()
+    }
+  }
+
+  override protected def sparkConf: SparkConf = {
+    val conf = super.sparkConf
+    conf.set("spark.hadoop.fs.s3a.access.key", userName)
+    conf.set("spark.hadoop.fs.s3a.secret.key", password)
+    conf.set("spark.hadoop.fs.s3a.endpoint", minioContainer.getS3URL)
+    conf.set("spark.hadoop.fs.s3a.path.style.access", "true")
+  }
+
+  private def createBucketIfNotExists(bucketName: String): Unit = {
+    val credentials = AwsBasicCredentials.create(userName, password)
+    val s3Client = S3Client
+      .builder()
+      .endpointOverride(URI.create(minioContainer.getS3URL))
+      .credentialsProvider(StaticCredentialsProvider.create(credentials))
+      .forcePathStyle(true)
+      .build()
+    try {
+      val bucketExists = Try {
+        
s3Client.headBucket(HeadBucketRequest.builder().bucket(bucketName).build())
+        true
+      }.getOrElse(false)
+
+      if (!bucketExists) {
+        val request = CreateBucketRequest.builder().bucket(bucketName).build()
+        s3Client.createBucket(request)
+      }
+    } finally {
+      s3Client.close()
+    }
+  }
+
+  private def writeTestParquetFile(filePath: String): Unit = {
+    val df = spark.range(0, 1000)
+    df.write.format("parquet").mode(SaveMode.Overwrite).save(filePath)
+  }
+
+  // native_iceberg_compat mode does not have comprehensive S3 support, so we 
don't run tests

Review Comment:
   We can make `native_iceberg_compat` honor Hadoop configuration just like 
`native_datafusion`, so that we can use this scanner impl to read plain parquet 
files. However, to my understanding `native_iceberg_compat` is primarily for 
integrating with iceberg, and iceberg configures S3 in a different way. This is 
an example of Spark catalog configuration that stores the warehouse in S3:
   
   ```
   spark-sql --conf 
spark.sql.catalog.my_catalog=org.apache.iceberg.spark.SparkCatalog \
       --conf 
spark.sql.catalog.my_catalog.warehouse=s3://my-bucket/my/key/prefix \
       --conf spark.sql.catalog.my_catalog.type=glue \
       --conf 
spark.sql.catalog.my_catalog.io-impl=org.apache.iceberg.aws.s3.S3FileIO \
       --conf spark.sql.catalog.my_catalog.s3.access-key-id=xxxxx \
       --conf spark.sql.catalog.my_catalog.s3.secret-access-key=xxxxxx
   ```
   
   Also, Apache Iceberg project has its own implementation of S3 file IO that 
directly depends on AWS SDK V2 and does not use Hadoop S3A, so Hadoop S3A 
configurations are not effective when reading S3 using iceberg. This requires 
that we take configurations from multiple sources to properly configure 
`native_iceberg_compat` scanner.



##########
native/Cargo.lock:
##########
@@ -375,6 +375,353 @@ version = "1.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
 
+[[package]]

Review Comment:
   The size of release jar built from this branch on macOS is 32MB, while the 
main branch is 30MB. The final jar size increases by 2MB.



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to