You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "hsiang-c (via GitHub)" <gi...@apache.org> on 2025/07/03 21:34:48 UTC
[PR] fix: [iceberg] Enable CometShuffleManager in Iceberg Spark tests [datafusion-comet]
hsiang-c opened a new pull request, #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #. https://github.com/apache/datafusion-comet/issues/1685
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
When we enabled Iceberg Spark tests w/ Comet-enabled Spark in https://github.com/apache/datafusion-comet/pull/1715
1. We didn't enable `CometShuffleManager`, this PR fixes it.
2. We implicitly load `org.apache.comet.CometSparkSessionExtensions` b/c Iceberg depends on patched Spark. This PR configures it explicitly using `.config("spark.plugins", "org.apache.spark.CometPlugin")` so that we can depend on open-source Spark.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "hsiang-c (via GitHub)" <gi...@apache.org>.
hsiang-c commented on PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#issuecomment-3075575929
Most of the exceptions in Iceberg Spark SQL Tests can be reproduced by
1. Follow the official guide to build Comet and Iceberg, configure Spark shell and populate the Iceberg table: https://datafusion.apache.org/comet/user-guide/iceberg.html
2. Query Iceberg metadata tables with an operator. Here is an example:
```sql
-- default is the catalog name used in local HadoopCatalog setup
scala> spark.sql(s"SELECT COUNT(*) from default.t1.snapshots").show()
25/07/15 13:06:16 ERROR Executor: Exception in task 0.0 in stage 2.0 (TID 2)
java.lang.ClassCastException: class org.apache.iceberg.spark.source.StructInternalRow cannot be cast to class org.apache.spark.sql.vectorized.ColumnarBatch (org.apache.iceberg.spark.source.StructInternalRow is in unnamed module of loader scala.reflect.internal.util.ScalaClassLoader$URLClassLoader @19ac93d2; org.apache.spark.sql.vectorized.ColumnarBatch is in unnamed module of loader 'app')
at org.apache.spark.sql.comet.CometBatchScanExec$$anon$1.next(CometBatchScanExec.scala:68)
at org.apache.spark.sql.comet.CometBatchScanExec$$anon$1.next(CometBatchScanExec.scala:57)
at org.apache.comet.CometBatchIterator.hasNext(CometBatchIterator.java:51)
at org.apache.comet.Native.executePlan(Native Method)
at org.apache.comet.CometExecIterator.$anonfun$getNextBatch$2(CometExecIterator.scala:155)
at org.apache.comet.CometExecIterator.$anonfun$getNextBatch$2$adapted(CometExecIterator.scala:154)
at org.apache.comet.vector.NativeUtil.getNextBatch(NativeUtil.scala:157)
at org.apache.comet.CometExecIterator.$anonfun$getNextBatch$1(CometExecIterator.scala:154)
at org.apache.comet.Tracing$.withTrace(Tracing.scala:31)
at org.apache.comet.CometExecIterator.getNextBatch(CometExecIterator.scala:152)
at org.apache.comet.CometExecIterator.hasNext(CometExecIterator.scala:203)
at scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:460)
at scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:460)
at org.apache.comet.CometBatchIterator.hasNext(CometBatchIterator.java:50)
at org.apache.comet.Native.executePlan(Native Method)
at org.apache.comet.CometExecIterator.$anonfun$getNextBatch$2(CometExecIterator.scala:155)
at org.apache.comet.CometExecIterator.$anonfun$getNextBatch$2$adapted(CometExecIterator.scala:154)
at org.apache.comet.vector.NativeUtil.getNextBatch(NativeUtil.scala:157)
at org.apache.comet.CometExecIterator.$anonfun$getNextBatch$1(CometExecIterator.scala:154)
at org.apache.comet.Tracing$.withTrace(Tracing.scala:31)
at org.apache.comet.CometExecIterator.getNextBatch(CometExecIterator.scala:152)
at org.apache.comet.CometExecIterator.hasNext(CometExecIterator.scala:203)
at org.apache.spark.sql.comet.execution.shuffle.CometNativeShuffleWriter.write(CometNativeShuffleWriter.scala:106)
at org.apache.spark.shuffle.ShuffleWriteProcessor.write(ShuffleWriteProcessor.scala:59)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:104)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:54)
at org.apache.spark.TaskContext.runTaskWithListeners(TaskContext.scala:166)
at org.apache.spark.scheduler.Task.run(Task.scala:141)
at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$4(Executor.scala:620)
at org.apache.spark.util.SparkErrorUtils.tryWithSafeFinally(SparkErrorUtils.scala:64)
at org.apache.spark.util.SparkErrorUtils.tryWithSafeFinally$(SparkErrorUtils.scala:61)
at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:94)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:623)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
```
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "hsiang-c (via GitHub)" <gi...@apache.org>.
hsiang-c commented on code in PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#discussion_r2286152103
##########
dev/diffs/iceberg/1.8.1.diff:
##########
@@ -1,186 +1,721 @@
+diff --git a/build.gradle b/build.gradle
+index 7327b38..7967109 100644
+--- a/build.gradle
++++ b/build.gradle
+@@ -780,6 +780,13 @@ project(':iceberg-parquet') {
+ implementation project(':iceberg-core')
+ implementation project(':iceberg-common')
+
++ implementation("org.apache.datafusion:comet-spark-spark${sparkVersionsString}_${scalaVersion}:${libs.versions.comet.get()}") {
++ exclude group: 'org.apache.arrow'
++ exclude group: 'org.apache.parquet'
++ exclude group: 'org.apache.spark'
++ exclude group: 'org.apache.iceberg'
++ }
++
+ implementation(libs.parquet.avro) {
+ exclude group: 'org.apache.avro', module: 'avro'
+ // already shaded by Parquet
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
-index 04ffa8f..d4107be 100644
+index 04ffa8f..cc0099c 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
-@@ -81,7 +81,7 @@ slf4j = "2.0.16"
+@@ -34,6 +34,7 @@ azuresdk-bom = "1.2.31"
+ awssdk-s3accessgrants = "2.3.0"
+ caffeine = "2.9.3"
+ calcite = "1.10.0"
++comet = "0.10.0-SNAPSHOT"
+ datasketches = "6.2.0"
+ delta-standalone = "3.3.0"
+ delta-spark = "3.3.0"
+@@ -81,7 +82,7 @@ slf4j = "2.0.16"
snowflake-jdbc = "3.22.0"
spark-hive33 = "3.3.4"
spark-hive34 = "3.4.4"
-spark-hive35 = "3.5.4"
-+spark-hive35 = "3.5.6-SNAPSHOT"
++spark-hive35 = "3.5.6"
sqlite-jdbc = "3.48.0.0"
testcontainers = "1.20.4"
tez010 = "0.10.4"
-diff --git a/spark/v3.4/build.gradle b/spark/v3.4/build.gradle
-index 6eb26e8..50cefce 100644
---- a/spark/v3.4/build.gradle
-+++ b/spark/v3.4/build.gradle
-@@ -75,7 +75,7 @@ project(":iceberg-spark:iceberg-spark-${sparkMajorVersion}_${scalaVersion}") {
- exclude group: 'org.roaringbitmap'
- }
-
-- compileOnly "org.apache.datafusion:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.5.0"
-+ compileOnly "org.apache.datafusion:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.10.0-SNAPSHOT"
-
- implementation libs.parquet.column
- implementation libs.parquet.hadoop
-@@ -185,7 +185,7 @@ project(":iceberg-spark:iceberg-spark-extensions-${sparkMajorVersion}_${scalaVer
- testImplementation libs.avro.avro
- testImplementation libs.parquet.hadoop
- testImplementation libs.junit.vintage.engine
-- testImplementation "org.apache.datafusion:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.5.0"
-+ testImplementation "org.apache.datafusion:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.10.0-SNAPSHOT"
-
- // Required because we remove antlr plugin dependencies from the compile configuration, see note above
- runtimeOnly libs.antlr.runtime
-@@ -260,6 +260,8 @@ project(":iceberg-spark:iceberg-spark-runtime-${sparkMajorVersion}_${scalaVersio
- integrationImplementation project(path: ':iceberg-hive-metastore', configuration: 'testArtifacts')
- integrationImplementation project(path: ":iceberg-spark:iceberg-spark-${sparkMajorVersion}_${scalaVersion}", configuration: 'testArtifacts')
- integrationImplementation project(path: ":iceberg-spark:iceberg-spark-extensions-${sparkMajorVersion}_${scalaVersion}", configuration: 'testArtifacts')
-+ integrationImplementation project(path: ':iceberg-parquet')
-+ integrationImplementation "org.apache.datafusion:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.10.0-SNAPSHOT"
-
- // runtime dependencies for running Hive Catalog based integration test
- integrationRuntimeOnly project(':iceberg-hive-metastore')
-@@ -297,8 +299,8 @@ project(":iceberg-spark:iceberg-spark-runtime-${sparkMajorVersion}_${scalaVersio
- relocate 'org.apache.avro', 'org.apache.iceberg.shaded.org.apache.avro'
- relocate 'avro.shaded', 'org.apache.iceberg.shaded.org.apache.avro.shaded'
- relocate 'com.thoughtworks.paranamer', 'org.apache.iceberg.shaded.com.thoughtworks.paranamer'
-- relocate 'org.apache.parquet', 'org.apache.iceberg.shaded.org.apache.parquet'
-- relocate 'shaded.parquet', 'org.apache.iceberg.shaded.org.apache.parquet.shaded'
-+// relocate 'org.apache.parquet', 'org.apache.iceberg.shaded.org.apache.parquet'
-+// relocate 'shaded.parquet', 'org.apache.iceberg.shaded.org.apache.parquet.shaded'
- relocate 'org.apache.orc', 'org.apache.iceberg.shaded.org.apache.orc'
- relocate 'io.airlift', 'org.apache.iceberg.shaded.io.airlift'
- relocate 'org.apache.hc.client5', 'org.apache.iceberg.shaded.org.apache.hc.client5'
-diff --git a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkSQLProperties.java b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkSQLProperties.java
-index 0ca1236..87daef4 100644
---- a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkSQLProperties.java
-+++ b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkSQLProperties.java
-@@ -29,7 +29,7 @@ public class SparkSQLProperties {
-
- // Controls which Parquet reader implementation to use
- public static final String PARQUET_READER_TYPE = "spark.sql.iceberg.parquet.reader-type";
-- public static final ParquetReaderType PARQUET_READER_TYPE_DEFAULT = ParquetReaderType.ICEBERG;
-+ public static final ParquetReaderType PARQUET_READER_TYPE_DEFAULT = ParquetReaderType.COMET;
-
- // Controls whether reading/writing timestamps without timezones is allowed
- @Deprecated
-diff --git a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/CometColumnReader.java b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/CometColumnReader.java
-index 4794863..0be31c1 100644
---- a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/CometColumnReader.java
-+++ b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/CometColumnReader.java
-@@ -20,11 +20,11 @@ package org.apache.iceberg.spark.data.vectorized;
+diff --git a/parquet/src/main/java/org/apache/iceberg/parquet/CometTypeUtils.java b/parquet/src/main/java/org/apache/iceberg/parquet/CometTypeUtils.java
+new file mode 100644
+index 0000000..ddf6c7d
+--- /dev/null
++++ b/parquet/src/main/java/org/apache/iceberg/parquet/CometTypeUtils.java
+@@ -0,0 +1,255 @@
++/*
++ * 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.iceberg.parquet;
++
++import java.util.Map;
++import org.apache.comet.parquet.ParquetColumnSpec;
++import org.apache.iceberg.relocated.com.google.common.collect.Maps;
++import org.apache.parquet.column.ColumnDescriptor;
++import org.apache.parquet.schema.LogicalTypeAnnotation;
++import org.apache.parquet.schema.PrimitiveType;
++import org.apache.parquet.schema.Type;
++import org.apache.parquet.schema.Types;
++
++public class CometTypeUtils {
++
++ private CometTypeUtils() {}
++
++ public static ParquetColumnSpec descriptorToParquetColumnSpec(ColumnDescriptor descriptor) {
++
++ String[] path = descriptor.getPath();
++ PrimitiveType primitiveType = descriptor.getPrimitiveType();
++ String physicalType = primitiveType.getPrimitiveTypeName().name();
++
++ int typeLength =
++ primitiveType.getPrimitiveTypeName() == PrimitiveType.PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY
++ ? primitiveType.getTypeLength()
++ : 0;
++
++ boolean isRepeated = primitiveType.getRepetition() == Type.Repetition.REPEATED;
++
++ // ToDo: extract this into a Util method
++ String logicalTypeName = null;
++ Map<String, String> logicalTypeParams = Maps.newHashMap();
++ LogicalTypeAnnotation logicalType = primitiveType.getLogicalTypeAnnotation();
++
++ if (logicalType != null) {
++ logicalTypeName = logicalType.getClass().getSimpleName();
++
++ // Handle specific logical types
++ if (logicalType instanceof LogicalTypeAnnotation.DecimalLogicalTypeAnnotation) {
++ LogicalTypeAnnotation.DecimalLogicalTypeAnnotation decimal =
++ (LogicalTypeAnnotation.DecimalLogicalTypeAnnotation) logicalType;
++ logicalTypeParams.put("precision", String.valueOf(decimal.getPrecision()));
++ logicalTypeParams.put("scale", String.valueOf(decimal.getScale()));
++ } else if (logicalType instanceof LogicalTypeAnnotation.TimestampLogicalTypeAnnotation) {
++ LogicalTypeAnnotation.TimestampLogicalTypeAnnotation timestamp =
++ (LogicalTypeAnnotation.TimestampLogicalTypeAnnotation) logicalType;
++ logicalTypeParams.put("isAdjustedToUTC", String.valueOf(timestamp.isAdjustedToUTC()));
++ logicalTypeParams.put("unit", timestamp.getUnit().name());
++ } else if (logicalType instanceof LogicalTypeAnnotation.TimeLogicalTypeAnnotation) {
++ LogicalTypeAnnotation.TimeLogicalTypeAnnotation time =
++ (LogicalTypeAnnotation.TimeLogicalTypeAnnotation) logicalType;
++ logicalTypeParams.put("isAdjustedToUTC", String.valueOf(time.isAdjustedToUTC()));
++ logicalTypeParams.put("unit", time.getUnit().name());
++ } else if (logicalType instanceof LogicalTypeAnnotation.IntLogicalTypeAnnotation) {
++ LogicalTypeAnnotation.IntLogicalTypeAnnotation intType =
++ (LogicalTypeAnnotation.IntLogicalTypeAnnotation) logicalType;
++ logicalTypeParams.put("isSigned", String.valueOf(intType.isSigned()));
++ logicalTypeParams.put("bitWidth", String.valueOf(intType.getBitWidth()));
++ }
++ }
++
++ return new ParquetColumnSpec(
++ 1, // ToDo: pass in the correct id
++ path,
++ physicalType,
++ typeLength,
++ isRepeated,
++ descriptor.getMaxDefinitionLevel(),
++ descriptor.getMaxRepetitionLevel(),
++ logicalTypeName,
++ logicalTypeParams);
++ }
++
++ public static ColumnDescriptor buildColumnDescriptor(ParquetColumnSpec columnSpec) {
++ PrimitiveType.PrimitiveTypeName primType =
++ PrimitiveType.PrimitiveTypeName.valueOf(columnSpec.getPhysicalType());
++
++ Type.Repetition repetition;
++ if (columnSpec.getMaxRepetitionLevel() > 0) {
++ repetition = Type.Repetition.REPEATED;
++ } else if (columnSpec.getMaxDefinitionLevel() > 0) {
++ repetition = Type.Repetition.OPTIONAL;
++ } else {
++ repetition = Type.Repetition.REQUIRED;
++ }
++
++ String name = columnSpec.getPath()[columnSpec.getPath().length - 1];
++ // Reconstruct the logical type from parameters
++ LogicalTypeAnnotation logicalType = null;
++ if (columnSpec.getLogicalTypeName() != null) {
++ logicalType =
++ reconstructLogicalType(
++ columnSpec.getLogicalTypeName(), columnSpec.getLogicalTypeParams());
++ }
++
++ PrimitiveType primitiveType;
++ if (primType == PrimitiveType.PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY) {
++ primitiveType =
++ org.apache.parquet.schema.Types.primitive(primType, repetition)
++ .length(columnSpec.getTypeLength())
++ .as(logicalType)
++ .id(columnSpec.getFieldId())
++ .named(name);
++ } else {
++ primitiveType =
++ Types.primitive(primType, repetition)
++ .as(logicalType)
++ .id(columnSpec.getFieldId())
++ .named(name);
++ }
++
++ return new ColumnDescriptor(
++ columnSpec.getPath(),
++ primitiveType,
++ columnSpec.getMaxRepetitionLevel(),
++ columnSpec.getMaxDefinitionLevel());
++ }
++
++ private static LogicalTypeAnnotation reconstructLogicalType(
++ String logicalTypeName, java.util.Map<String, String> params) {
++
++ switch (logicalTypeName) {
++ // MAP
++ case "MapLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.mapType();
++
++ // LIST
++ case "ListLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.listType();
++
++ // STRING
++ case "StringLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.stringType();
++
++ // MAP_KEY_VALUE
++ case "MapKeyValueLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.MapKeyValueTypeAnnotation.getInstance();
++
++ // ENUM
++ case "EnumLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.enumType();
++
++ // DECIMAL
++ case "DecimalLogicalTypeAnnotation":
++ if (!params.containsKey("scale") || !params.containsKey("precision")) {
++ throw new IllegalArgumentException(
++ "Missing required parameters for DecimalLogicalTypeAnnotation: " + params);
++ }
++ int scale = Integer.parseInt(params.get("scale"));
++ int precision = Integer.parseInt(params.get("precision"));
++ return LogicalTypeAnnotation.decimalType(scale, precision);
++
++ // DATE
++ case "DateLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.dateType();
++
++ // TIME
++ case "TimeLogicalTypeAnnotation":
++ if (!params.containsKey("isAdjustedToUTC") || !params.containsKey("unit")) {
++ throw new IllegalArgumentException(
++ "Missing required parameters for TimeLogicalTypeAnnotation: " + params);
++ }
++
++ boolean isUTC = Boolean.parseBoolean(params.get("isAdjustedToUTC"));
++ String timeUnitStr = params.get("unit");
++
++ LogicalTypeAnnotation.TimeUnit timeUnit;
++ switch (timeUnitStr) {
++ case "MILLIS":
++ timeUnit = LogicalTypeAnnotation.TimeUnit.MILLIS;
++ break;
++ case "MICROS":
++ timeUnit = LogicalTypeAnnotation.TimeUnit.MICROS;
++ break;
++ case "NANOS":
++ timeUnit = LogicalTypeAnnotation.TimeUnit.NANOS;
++ break;
++ default:
++ throw new IllegalArgumentException("Unknown time unit: " + timeUnitStr);
++ }
++ return LogicalTypeAnnotation.timeType(isUTC, timeUnit);
++
++ // TIMESTAMP
++ case "TimestampLogicalTypeAnnotation":
++ if (!params.containsKey("isAdjustedToUTC") || !params.containsKey("unit")) {
++ throw new IllegalArgumentException(
++ "Missing required parameters for TimestampLogicalTypeAnnotation: " + params);
++ }
++ boolean isAdjustedToUTC = Boolean.parseBoolean(params.get("isAdjustedToUTC"));
++ String unitStr = params.get("unit");
++
++ LogicalTypeAnnotation.TimeUnit unit;
++ switch (unitStr) {
++ case "MILLIS":
++ unit = LogicalTypeAnnotation.TimeUnit.MILLIS;
++ break;
++ case "MICROS":
++ unit = LogicalTypeAnnotation.TimeUnit.MICROS;
++ break;
++ case "NANOS":
++ unit = LogicalTypeAnnotation.TimeUnit.NANOS;
++ break;
++ default:
++ throw new IllegalArgumentException("Unknown timestamp unit: " + unitStr);
++ }
++ return LogicalTypeAnnotation.timestampType(isAdjustedToUTC, unit);
++
++ // INTEGER
++ case "IntLogicalTypeAnnotation":
++ if (!params.containsKey("isSigned") || !params.containsKey("bitWidth")) {
++ throw new IllegalArgumentException(
++ "Missing required parameters for IntLogicalTypeAnnotation: " + params);
++ }
++ boolean isSigned = Boolean.parseBoolean(params.get("isSigned"));
++ int bitWidth = Integer.parseInt(params.get("bitWidth"));
++ return LogicalTypeAnnotation.intType(bitWidth, isSigned);
++
++ // JSON
++ case "JsonLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.jsonType();
++
++ // BSON
++ case "BsonLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.bsonType();
++
++ // UUID
++ case "UUIDLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.uuidType();
++
++ // INTERVAL
++ case "IntervalLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.IntervalLogicalTypeAnnotation.getInstance();
++
++ default:
++ throw new IllegalArgumentException("Unknown logical type: " + logicalTypeName);
++ }
++ }
++}
+diff --git a/parquet/src/main/java/org/apache/iceberg/parquet/CometVectorizedParquetReader.java b/parquet/src/main/java/org/apache/iceberg/parquet/CometVectorizedParquetReader.java
+new file mode 100644
+index 0000000..88b195b
+--- /dev/null
++++ b/parquet/src/main/java/org/apache/iceberg/parquet/CometVectorizedParquetReader.java
+@@ -0,0 +1,255 @@
++/*
++ * 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.iceberg.parquet;
++
++import java.io.IOException;
++import java.io.UncheckedIOException;
++import java.nio.ByteBuffer;
++import java.util.List;
++import java.util.Map;
++import java.util.NoSuchElementException;
++import java.util.function.Function;
++import org.apache.comet.parquet.FileReader;
++import org.apache.comet.parquet.ParquetColumnSpec;
++import org.apache.comet.parquet.ReadOptions;
++import org.apache.comet.parquet.RowGroupReader;
++import org.apache.comet.parquet.WrappedInputFile;
++import org.apache.hadoop.conf.Configuration;
++import org.apache.iceberg.Schema;
++import org.apache.iceberg.exceptions.RuntimeIOException;
++import org.apache.iceberg.expressions.Expression;
++import org.apache.iceberg.expressions.Expressions;
++import org.apache.iceberg.io.CloseableGroup;
++import org.apache.iceberg.io.CloseableIterable;
++import org.apache.iceberg.io.CloseableIterator;
++import org.apache.iceberg.io.InputFile;
++import org.apache.iceberg.mapping.NameMapping;
++import org.apache.iceberg.relocated.com.google.common.collect.Lists;
++import org.apache.iceberg.util.ByteBuffers;
++import org.apache.parquet.ParquetReadOptions;
++import org.apache.parquet.column.ColumnDescriptor;
++import org.apache.parquet.hadoop.metadata.ColumnChunkMetaData;
++import org.apache.parquet.hadoop.metadata.ColumnPath;
++import org.apache.parquet.schema.MessageType;
++
++public class CometVectorizedParquetReader<T> extends CloseableGroup
++ implements CloseableIterable<T> {
++ private final InputFile input;
++ private final ParquetReadOptions options;
++ private final Schema expectedSchema;
++ private final Function<MessageType, VectorizedReader<?>> batchReaderFunc;
++ private final Expression filter;
++ private final boolean reuseContainers;
++ private final boolean caseSensitive;
++ private final int batchSize;
++ private final NameMapping nameMapping;
++ private final Map<String, String> properties;
++ private Long start = null;
++ private Long length = null;
++ private ByteBuffer fileEncryptionKey = null;
++ private ByteBuffer fileAADPrefix = null;
++
++ public CometVectorizedParquetReader(
++ InputFile input,
++ Schema expectedSchema,
++ ParquetReadOptions options,
++ Function<MessageType, VectorizedReader<?>> readerFunc,
++ NameMapping nameMapping,
++ Expression filter,
++ boolean reuseContainers,
++ boolean caseSensitive,
++ int maxRecordsPerBatch,
++ Map<String, String> properties,
++ Long start,
++ Long length,
++ ByteBuffer fileEncryptionKey,
++ ByteBuffer fileAADPrefix) {
++ this.input = input;
++ this.expectedSchema = expectedSchema;
++ this.options = options;
++ this.batchReaderFunc = readerFunc;
++ // replace alwaysTrue with null to avoid extra work evaluating a trivial filter
++ this.filter = filter == Expressions.alwaysTrue() ? null : filter;
++ this.reuseContainers = reuseContainers;
++ this.caseSensitive = caseSensitive;
++ this.batchSize = maxRecordsPerBatch;
++ this.nameMapping = nameMapping;
++ this.properties = properties;
++ this.start = start;
++ this.length = length;
++ this.fileEncryptionKey = fileEncryptionKey;
++ this.fileAADPrefix = fileAADPrefix;
++ }
++
++ private ReadConf conf = null;
++
++ private ReadConf init() {
++ if (conf == null) {
++ ReadConf readConf =
++ new ReadConf(
++ input,
++ options,
++ expectedSchema,
++ filter,
++ null,
++ batchReaderFunc,
++ nameMapping,
++ reuseContainers,
++ caseSensitive,
++ batchSize);
++ this.conf = readConf.copy();
++ return readConf;
++ }
++ return conf;
++ }
++
++ @Override
++ public CloseableIterator<T> iterator() {
++ FileIterator<T> iter =
++ new FileIterator<>(init(), properties, start, length, fileEncryptionKey, fileAADPrefix);
++ addCloseable(iter);
++ return iter;
++ }
++
++ private static class FileIterator<T> implements CloseableIterator<T> {
++ // private final ParquetFileReader reader;
++ private final boolean[] shouldSkip;
++ private final VectorizedReader<T> model;
++ private final long totalValues;
++ private final int batchSize;
++ private final List<Map<ColumnPath, ColumnChunkMetaData>> columnChunkMetadata;
++ private final boolean reuseContainers;
++ private int nextRowGroup = 0;
++ private long nextRowGroupStart = 0;
++ private long valuesRead = 0;
++ private T last = null;
++ private final FileReader cometReader;
++
++ FileIterator(
++ ReadConf conf,
++ Map<String, String> properties,
++ Long start,
++ Long length,
++ ByteBuffer fileEncryptionKey,
++ ByteBuffer fileAADPrefix) {
++ this.shouldSkip = conf.shouldSkip();
++ this.totalValues = conf.totalValues();
++ this.reuseContainers = conf.reuseContainers();
++ this.model = conf.vectorizedModel();
++ this.batchSize = conf.batchSize();
++ this.model.setBatchSize(this.batchSize);
++ this.columnChunkMetadata = conf.columnChunkMetadataForRowGroups();
++ this.cometReader =
++ newCometReader(
++ conf.file(),
++ conf.projection(),
++ properties,
++ start,
++ length,
++ fileEncryptionKey,
++ fileAADPrefix);
++ }
++
++ private FileReader newCometReader(
++ InputFile file,
++ MessageType projection,
++ Map<String, String> properties,
++ Long start,
++ Long length,
++ ByteBuffer fileEncryptionKey,
++ ByteBuffer fileAADPrefix) {
++ try {
++ ReadOptions cometOptions = ReadOptions.builder(new Configuration()).build();
++
++ FileReader fileReader =
++ new FileReader(
++ new WrappedInputFile(file),
++ cometOptions,
++ properties,
++ start,
++ length,
++ ByteBuffers.toByteArray(fileEncryptionKey),
++ ByteBuffers.toByteArray(fileAADPrefix));
++
++ List<ColumnDescriptor> columnDescriptors = projection.getColumns();
++
++ List<ParquetColumnSpec> specs = Lists.newArrayList();
++
++ for (ColumnDescriptor descriptor : columnDescriptors) {
++ ParquetColumnSpec spec = CometTypeUtils.descriptorToParquetColumnSpec(descriptor);
++ specs.add(spec);
++ }
++
++ fileReader.setRequestedSchemaFromSpecs(specs);
++ return fileReader;
++ } catch (IOException e) {
++ throw new UncheckedIOException("Failed to open Parquet file: " + file.location(), e);
++ }
++ }
++
++ @Override
++ public boolean hasNext() {
++ return valuesRead < totalValues;
++ }
++
++ @Override
++ public T next() {
++ if (!hasNext()) {
++ throw new NoSuchElementException();
++ }
++ if (valuesRead >= nextRowGroupStart) {
++ advance();
++ }
++
++ // batchSize is an integer, so casting to integer is safe
++ int numValuesToRead = (int) Math.min(nextRowGroupStart - valuesRead, batchSize);
++ if (reuseContainers) {
++ this.last = model.read(last, numValuesToRead);
++ } else {
++ this.last = model.read(null, numValuesToRead);
++ }
++ valuesRead += numValuesToRead;
++
++ return last;
++ }
++
++ private void advance() {
++ while (shouldSkip[nextRowGroup]) {
++ nextRowGroup += 1;
++ cometReader.skipNextRowGroup();
++ }
++ RowGroupReader pages;
++ try {
++ pages = cometReader.readNextRowGroup();
++ } catch (IOException e) {
++ throw new RuntimeIOException(e);
++ }
++
++ model.setRowGroupInfo(pages, columnChunkMetadata.get(nextRowGroup));
++ nextRowGroupStart += pages.getRowCount();
++ nextRowGroup += 1;
++ }
++
++ @Override
++ public void close() throws IOException {
++ model.close();
++ cometReader.close();
++ }
++ }
++}
+diff --git a/parquet/src/main/java/org/apache/iceberg/parquet/Parquet.java b/parquet/src/main/java/org/apache/iceberg/parquet/Parquet.java
+<<<<<<< Updated upstream
+index 2c37a52..503dbd6 100644
+=======
+index 2c37a52..3442cfc 100644
+>>>>>>> Stashed changes
Review Comment:
Sorry about that, fixed now.
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#issuecomment-3033918578
## [Codecov](https://app.codecov.io/gh/apache/datafusion-comet/pull/1987?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 32.72%. Comparing base [(`f09f8af`)](https://app.codecov.io/gh/apache/datafusion-comet/commit/f09f8af64c6599255e116a376f4f008f2fd63b43?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`b574107`)](https://app.codecov.io/gh/apache/datafusion-comet/commit/b574107723ec9e9c65fe641e39e55bd47ac4b515?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 309 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #1987 +/- ##
=============================================
- Coverage 56.12% 32.72% -23.41%
+ Complexity 976 799 -177
=============================================
Files 119 133 +14
Lines 11743 12951 +1208
Branches 2251 2411 +160
=============================================
- Hits 6591 4238 -2353
- Misses 4012 7759 +3747
+ Partials 1140 954 -186
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/datafusion-comet/pull/1987?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "hsiang-c (via GitHub)" <gi...@apache.org>.
hsiang-c commented on code in PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#discussion_r2183887303
##########
dev/diffs/iceberg/1.8.1.diff:
##########
@@ -195,6 +195,100 @@ index e2d2c7a..d23acef 100644
relocate 'org.apache.orc', 'org.apache.iceberg.shaded.org.apache.orc'
relocate 'io.airlift', 'org.apache.iceberg.shaded.io.airlift'
relocate 'org.apache.hc.client5', 'org.apache.iceberg.shaded.org.apache.hc.client5'
+diff --git a/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/ExtensionsTestBase.java b/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/ExtensionsTestBase.java
+index 578845e..9476f19 100644
+--- a/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/ExtensionsTestBase.java
++++ b/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/ExtensionsTestBase.java
+@@ -57,6 +57,8 @@ public abstract class ExtensionsTestBase extends CatalogTestBase {
+ .config("spark.sql.legacy.respectNullabilityInTextDatasetConversion", "true")
+ .config(
+ SQLConf.ADAPTIVE_EXECUTION_ENABLED().key(), String.valueOf(RANDOM.nextBoolean()))
++ .config("spark.plugins", "org.apache.spark.CometPlugin")
Review Comment:
@kazuyukitanimura
We're lucky in some cases b/c `TestBase` and `ExtensionsTestBase` consolidate `SparkSession.Builder` in the abstract class.
Unfortunately, other test classes and `jmh` build their own `SparkSession` 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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#discussion_r2260902271
##########
.github/workflows/iceberg_spark_test.yml:
##########
@@ -63,24 +63,96 @@ jobs:
with:
rust-version: ${{env.RUST_VERSION}}
jdk-version: ${{ matrix.java-version }}
+ - name: Build Comet
+ shell: bash
+ run: |
+ PROFILES="-Pspark-${{matrix.spark-version.short}} -Pscala-${{matrix.scala-version}}" make release
- name: Setup Iceberg
uses: ./.github/actions/setup-iceberg-builder
with:
iceberg-version: ${{ matrix.iceberg-version.full }}
- scala-version: ${{ matrix.scala-version }}
- spark-short-version: ${{ matrix.spark-version.short }}
- - name: Build local Spark jar with comet patch
- uses: ./.github/actions/setup-spark-local-jar
- with:
- spark-short-version: ${{ matrix.spark-version.short }}
- spark-version: ${{ matrix.spark-version.full }}
- scala-version: ${{ matrix.scala-version }}
- name: Run Iceberg Spark tests
run: |
cd apache-iceberg
rm -rf /root/.m2/repository/org/apache/parquet # somehow parquet cache requires cleanups
- ENABLE_COMET=true ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
- :iceberg-spark:iceberg-spark-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:check \
- :iceberg-spark:iceberg-spark-extensions-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:check \
- :iceberg-spark:iceberg-spark-runtime-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:check \
+ ENABLE_COMET=true COMET_PARQUET_SCAN_IMPL=native_iceberg_compat ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
+ :iceberg-spark:iceberg-spark-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:test \
-Pquick=true -x javadoc
+
+ iceberg-spark-extensions:
+ if: contains(github.event.pull_request.title, '[iceberg]')
+ strategy:
+ matrix:
+ os: [ubuntu-24.04]
+ java-version: [11, 17]
+ iceberg-version: [{short: '1.8', full: '1.8.1'}]
+ spark-version: [{short: '3.5', full: '3.5.6'}]
+ scala-version: ['2.13']
+ fail-fast: false
+ name: iceberg-spark-extensions/${{ matrix.os }}/iceberg-${{ matrix.iceberg-version.full }}/spark-${{ matrix.spark-version.full }}/scala-${{ matrix.scala-version }}/java-${{ matrix.java-version }}
+ runs-on: ${{ matrix.os }}
+ container:
+ image: amd64/rust
+ env:
+ SPARK_LOCAL_IP: localhost
+ steps:
+ - uses: actions/checkout@v4
+ - name: Setup Rust & Java toolchain
+ uses: ./.github/actions/setup-builder
+ with:
+ rust-version: ${{env.RUST_VERSION}}
+ jdk-version: ${{ matrix.java-version }}
+ - name: Build Comet
+ shell: bash
+ run: |
+ PROFILES="-Pspark-${{matrix.spark-version.short}} -Pscala-${{matrix.scala-version}}" make release
+ - name: Setup Iceberg
+ uses: ./.github/actions/setup-iceberg-builder
+ with:
+ iceberg-version: ${{ matrix.iceberg-version.full }}
+ - name: Run Iceberg Spark extensions tests
+ run: |
+ cd apache-iceberg
+ rm -rf /root/.m2/repository/org/apache/parquet # somehow parquet cache requires cleanups
+ ENABLE_COMET=true COMET_PARQUET_SCAN_IMPL=native_iceberg_compat ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
+ :iceberg-spark:iceberg-spark-extensions-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:test \
+ -Pquick=true -x javadoc
+
+ iceberg-spark-runtime:
+ if: contains(github.event.pull_request.title, '[iceberg]')
+ strategy:
+ matrix:
+ os: [ubuntu-24.04]
+ java-version: [11, 17]
+ iceberg-version: [{short: '1.8', full: '1.8.1'}]
+ spark-version: [{short: '3.5', full: '3.5.6'}]
+ scala-version: ['2.13']
+ fail-fast: false
+ name: iceberg-spark-runtime/${{ matrix.os }}/iceberg-${{ matrix.iceberg-version.full }}/spark-${{ matrix.spark-version.full }}/scala-${{ matrix.scala-version }}/java-${{ matrix.java-version }}
+ runs-on: ${{ matrix.os }}
+ container:
+ image: amd64/rust
+ env:
+ SPARK_LOCAL_IP: localhost
+ steps:
+ - uses: actions/checkout@v4
+ - name: Setup Rust & Java toolchain
+ uses: ./.github/actions/setup-builder
+ with:
+ rust-version: ${{env.RUST_VERSION}}
+ jdk-version: ${{ matrix.java-version }}
+ - name: Build Comet
+ shell: bash
+ run: |
+ PROFILES="-Pspark-${{matrix.spark-version.short}} -Pscala-${{matrix.scala-version}}" make release
+ - name: Setup Iceberg
+ uses: ./.github/actions/setup-iceberg-builder
+ with:
+ iceberg-version: ${{ matrix.iceberg-version.full }}
+ - name: Run Iceberg Spark runtime tests
+ run: |
+ cd apache-iceberg
+ rm -rf /root/.m2/repository/org/apache/parquet # somehow parquet cache requires cleanups
+ ENABLE_COMET=true COMET_PARQUET_SCAN_IMPL=native_iceberg_compat ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
Review Comment:
Same commet as above.
```suggestion
ENABLE_COMET=true ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
```
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#discussion_r2260899713
##########
.github/workflows/iceberg_spark_test.yml:
##########
@@ -63,24 +63,96 @@ jobs:
with:
rust-version: ${{env.RUST_VERSION}}
jdk-version: ${{ matrix.java-version }}
+ - name: Build Comet
+ shell: bash
+ run: |
+ PROFILES="-Pspark-${{matrix.spark-version.short}} -Pscala-${{matrix.scala-version}}" make release
- name: Setup Iceberg
uses: ./.github/actions/setup-iceberg-builder
with:
iceberg-version: ${{ matrix.iceberg-version.full }}
- scala-version: ${{ matrix.scala-version }}
- spark-short-version: ${{ matrix.spark-version.short }}
- - name: Build local Spark jar with comet patch
- uses: ./.github/actions/setup-spark-local-jar
- with:
- spark-short-version: ${{ matrix.spark-version.short }}
- spark-version: ${{ matrix.spark-version.full }}
- scala-version: ${{ matrix.scala-version }}
- name: Run Iceberg Spark tests
run: |
cd apache-iceberg
rm -rf /root/.m2/repository/org/apache/parquet # somehow parquet cache requires cleanups
- ENABLE_COMET=true ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
- :iceberg-spark:iceberg-spark-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:check \
- :iceberg-spark:iceberg-spark-extensions-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:check \
- :iceberg-spark:iceberg-spark-runtime-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:check \
+ ENABLE_COMET=true COMET_PARQUET_SCAN_IMPL=native_iceberg_compat ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
Review Comment:
I don't think that we want to set `COMET_PARQUET_SCAN_IMPL` here. The Iceberg integration explicitly calls low level APIS for `native_comet` scan.
```suggestion
ENABLE_COMET=true ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
```
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#discussion_r2285513673
##########
dev/diffs/iceberg/1.8.1.diff:
##########
@@ -1,186 +1,721 @@
+diff --git a/build.gradle b/build.gradle
+index 7327b38..7967109 100644
+--- a/build.gradle
++++ b/build.gradle
+@@ -780,6 +780,13 @@ project(':iceberg-parquet') {
+ implementation project(':iceberg-core')
+ implementation project(':iceberg-common')
+
++ implementation("org.apache.datafusion:comet-spark-spark${sparkVersionsString}_${scalaVersion}:${libs.versions.comet.get()}") {
++ exclude group: 'org.apache.arrow'
++ exclude group: 'org.apache.parquet'
++ exclude group: 'org.apache.spark'
++ exclude group: 'org.apache.iceberg'
++ }
++
+ implementation(libs.parquet.avro) {
+ exclude group: 'org.apache.avro', module: 'avro'
+ // already shaded by Parquet
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
-index 04ffa8f..d4107be 100644
+index 04ffa8f..cc0099c 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
-@@ -81,7 +81,7 @@ slf4j = "2.0.16"
+@@ -34,6 +34,7 @@ azuresdk-bom = "1.2.31"
+ awssdk-s3accessgrants = "2.3.0"
+ caffeine = "2.9.3"
+ calcite = "1.10.0"
++comet = "0.10.0-SNAPSHOT"
+ datasketches = "6.2.0"
+ delta-standalone = "3.3.0"
+ delta-spark = "3.3.0"
+@@ -81,7 +82,7 @@ slf4j = "2.0.16"
snowflake-jdbc = "3.22.0"
spark-hive33 = "3.3.4"
spark-hive34 = "3.4.4"
-spark-hive35 = "3.5.4"
-+spark-hive35 = "3.5.6-SNAPSHOT"
++spark-hive35 = "3.5.6"
sqlite-jdbc = "3.48.0.0"
testcontainers = "1.20.4"
tez010 = "0.10.4"
-diff --git a/spark/v3.4/build.gradle b/spark/v3.4/build.gradle
-index 6eb26e8..50cefce 100644
---- a/spark/v3.4/build.gradle
-+++ b/spark/v3.4/build.gradle
-@@ -75,7 +75,7 @@ project(":iceberg-spark:iceberg-spark-${sparkMajorVersion}_${scalaVersion}") {
- exclude group: 'org.roaringbitmap'
- }
-
-- compileOnly "org.apache.datafusion:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.5.0"
-+ compileOnly "org.apache.datafusion:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.10.0-SNAPSHOT"
-
- implementation libs.parquet.column
- implementation libs.parquet.hadoop
-@@ -185,7 +185,7 @@ project(":iceberg-spark:iceberg-spark-extensions-${sparkMajorVersion}_${scalaVer
- testImplementation libs.avro.avro
- testImplementation libs.parquet.hadoop
- testImplementation libs.junit.vintage.engine
-- testImplementation "org.apache.datafusion:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.5.0"
-+ testImplementation "org.apache.datafusion:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.10.0-SNAPSHOT"
-
- // Required because we remove antlr plugin dependencies from the compile configuration, see note above
- runtimeOnly libs.antlr.runtime
-@@ -260,6 +260,8 @@ project(":iceberg-spark:iceberg-spark-runtime-${sparkMajorVersion}_${scalaVersio
- integrationImplementation project(path: ':iceberg-hive-metastore', configuration: 'testArtifacts')
- integrationImplementation project(path: ":iceberg-spark:iceberg-spark-${sparkMajorVersion}_${scalaVersion}", configuration: 'testArtifacts')
- integrationImplementation project(path: ":iceberg-spark:iceberg-spark-extensions-${sparkMajorVersion}_${scalaVersion}", configuration: 'testArtifacts')
-+ integrationImplementation project(path: ':iceberg-parquet')
-+ integrationImplementation "org.apache.datafusion:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.10.0-SNAPSHOT"
-
- // runtime dependencies for running Hive Catalog based integration test
- integrationRuntimeOnly project(':iceberg-hive-metastore')
-@@ -297,8 +299,8 @@ project(":iceberg-spark:iceberg-spark-runtime-${sparkMajorVersion}_${scalaVersio
- relocate 'org.apache.avro', 'org.apache.iceberg.shaded.org.apache.avro'
- relocate 'avro.shaded', 'org.apache.iceberg.shaded.org.apache.avro.shaded'
- relocate 'com.thoughtworks.paranamer', 'org.apache.iceberg.shaded.com.thoughtworks.paranamer'
-- relocate 'org.apache.parquet', 'org.apache.iceberg.shaded.org.apache.parquet'
-- relocate 'shaded.parquet', 'org.apache.iceberg.shaded.org.apache.parquet.shaded'
-+// relocate 'org.apache.parquet', 'org.apache.iceberg.shaded.org.apache.parquet'
-+// relocate 'shaded.parquet', 'org.apache.iceberg.shaded.org.apache.parquet.shaded'
- relocate 'org.apache.orc', 'org.apache.iceberg.shaded.org.apache.orc'
- relocate 'io.airlift', 'org.apache.iceberg.shaded.io.airlift'
- relocate 'org.apache.hc.client5', 'org.apache.iceberg.shaded.org.apache.hc.client5'
-diff --git a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkSQLProperties.java b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkSQLProperties.java
-index 0ca1236..87daef4 100644
---- a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkSQLProperties.java
-+++ b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkSQLProperties.java
-@@ -29,7 +29,7 @@ public class SparkSQLProperties {
-
- // Controls which Parquet reader implementation to use
- public static final String PARQUET_READER_TYPE = "spark.sql.iceberg.parquet.reader-type";
-- public static final ParquetReaderType PARQUET_READER_TYPE_DEFAULT = ParquetReaderType.ICEBERG;
-+ public static final ParquetReaderType PARQUET_READER_TYPE_DEFAULT = ParquetReaderType.COMET;
-
- // Controls whether reading/writing timestamps without timezones is allowed
- @Deprecated
-diff --git a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/CometColumnReader.java b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/CometColumnReader.java
-index 4794863..0be31c1 100644
---- a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/CometColumnReader.java
-+++ b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/CometColumnReader.java
-@@ -20,11 +20,11 @@ package org.apache.iceberg.spark.data.vectorized;
+diff --git a/parquet/src/main/java/org/apache/iceberg/parquet/CometTypeUtils.java b/parquet/src/main/java/org/apache/iceberg/parquet/CometTypeUtils.java
+new file mode 100644
+index 0000000..ddf6c7d
+--- /dev/null
++++ b/parquet/src/main/java/org/apache/iceberg/parquet/CometTypeUtils.java
+@@ -0,0 +1,255 @@
++/*
++ * 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.iceberg.parquet;
++
++import java.util.Map;
++import org.apache.comet.parquet.ParquetColumnSpec;
++import org.apache.iceberg.relocated.com.google.common.collect.Maps;
++import org.apache.parquet.column.ColumnDescriptor;
++import org.apache.parquet.schema.LogicalTypeAnnotation;
++import org.apache.parquet.schema.PrimitiveType;
++import org.apache.parquet.schema.Type;
++import org.apache.parquet.schema.Types;
++
++public class CometTypeUtils {
++
++ private CometTypeUtils() {}
++
++ public static ParquetColumnSpec descriptorToParquetColumnSpec(ColumnDescriptor descriptor) {
++
++ String[] path = descriptor.getPath();
++ PrimitiveType primitiveType = descriptor.getPrimitiveType();
++ String physicalType = primitiveType.getPrimitiveTypeName().name();
++
++ int typeLength =
++ primitiveType.getPrimitiveTypeName() == PrimitiveType.PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY
++ ? primitiveType.getTypeLength()
++ : 0;
++
++ boolean isRepeated = primitiveType.getRepetition() == Type.Repetition.REPEATED;
++
++ // ToDo: extract this into a Util method
++ String logicalTypeName = null;
++ Map<String, String> logicalTypeParams = Maps.newHashMap();
++ LogicalTypeAnnotation logicalType = primitiveType.getLogicalTypeAnnotation();
++
++ if (logicalType != null) {
++ logicalTypeName = logicalType.getClass().getSimpleName();
++
++ // Handle specific logical types
++ if (logicalType instanceof LogicalTypeAnnotation.DecimalLogicalTypeAnnotation) {
++ LogicalTypeAnnotation.DecimalLogicalTypeAnnotation decimal =
++ (LogicalTypeAnnotation.DecimalLogicalTypeAnnotation) logicalType;
++ logicalTypeParams.put("precision", String.valueOf(decimal.getPrecision()));
++ logicalTypeParams.put("scale", String.valueOf(decimal.getScale()));
++ } else if (logicalType instanceof LogicalTypeAnnotation.TimestampLogicalTypeAnnotation) {
++ LogicalTypeAnnotation.TimestampLogicalTypeAnnotation timestamp =
++ (LogicalTypeAnnotation.TimestampLogicalTypeAnnotation) logicalType;
++ logicalTypeParams.put("isAdjustedToUTC", String.valueOf(timestamp.isAdjustedToUTC()));
++ logicalTypeParams.put("unit", timestamp.getUnit().name());
++ } else if (logicalType instanceof LogicalTypeAnnotation.TimeLogicalTypeAnnotation) {
++ LogicalTypeAnnotation.TimeLogicalTypeAnnotation time =
++ (LogicalTypeAnnotation.TimeLogicalTypeAnnotation) logicalType;
++ logicalTypeParams.put("isAdjustedToUTC", String.valueOf(time.isAdjustedToUTC()));
++ logicalTypeParams.put("unit", time.getUnit().name());
++ } else if (logicalType instanceof LogicalTypeAnnotation.IntLogicalTypeAnnotation) {
++ LogicalTypeAnnotation.IntLogicalTypeAnnotation intType =
++ (LogicalTypeAnnotation.IntLogicalTypeAnnotation) logicalType;
++ logicalTypeParams.put("isSigned", String.valueOf(intType.isSigned()));
++ logicalTypeParams.put("bitWidth", String.valueOf(intType.getBitWidth()));
++ }
++ }
++
++ return new ParquetColumnSpec(
++ 1, // ToDo: pass in the correct id
++ path,
++ physicalType,
++ typeLength,
++ isRepeated,
++ descriptor.getMaxDefinitionLevel(),
++ descriptor.getMaxRepetitionLevel(),
++ logicalTypeName,
++ logicalTypeParams);
++ }
++
++ public static ColumnDescriptor buildColumnDescriptor(ParquetColumnSpec columnSpec) {
++ PrimitiveType.PrimitiveTypeName primType =
++ PrimitiveType.PrimitiveTypeName.valueOf(columnSpec.getPhysicalType());
++
++ Type.Repetition repetition;
++ if (columnSpec.getMaxRepetitionLevel() > 0) {
++ repetition = Type.Repetition.REPEATED;
++ } else if (columnSpec.getMaxDefinitionLevel() > 0) {
++ repetition = Type.Repetition.OPTIONAL;
++ } else {
++ repetition = Type.Repetition.REQUIRED;
++ }
++
++ String name = columnSpec.getPath()[columnSpec.getPath().length - 1];
++ // Reconstruct the logical type from parameters
++ LogicalTypeAnnotation logicalType = null;
++ if (columnSpec.getLogicalTypeName() != null) {
++ logicalType =
++ reconstructLogicalType(
++ columnSpec.getLogicalTypeName(), columnSpec.getLogicalTypeParams());
++ }
++
++ PrimitiveType primitiveType;
++ if (primType == PrimitiveType.PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY) {
++ primitiveType =
++ org.apache.parquet.schema.Types.primitive(primType, repetition)
++ .length(columnSpec.getTypeLength())
++ .as(logicalType)
++ .id(columnSpec.getFieldId())
++ .named(name);
++ } else {
++ primitiveType =
++ Types.primitive(primType, repetition)
++ .as(logicalType)
++ .id(columnSpec.getFieldId())
++ .named(name);
++ }
++
++ return new ColumnDescriptor(
++ columnSpec.getPath(),
++ primitiveType,
++ columnSpec.getMaxRepetitionLevel(),
++ columnSpec.getMaxDefinitionLevel());
++ }
++
++ private static LogicalTypeAnnotation reconstructLogicalType(
++ String logicalTypeName, java.util.Map<String, String> params) {
++
++ switch (logicalTypeName) {
++ // MAP
++ case "MapLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.mapType();
++
++ // LIST
++ case "ListLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.listType();
++
++ // STRING
++ case "StringLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.stringType();
++
++ // MAP_KEY_VALUE
++ case "MapKeyValueLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.MapKeyValueTypeAnnotation.getInstance();
++
++ // ENUM
++ case "EnumLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.enumType();
++
++ // DECIMAL
++ case "DecimalLogicalTypeAnnotation":
++ if (!params.containsKey("scale") || !params.containsKey("precision")) {
++ throw new IllegalArgumentException(
++ "Missing required parameters for DecimalLogicalTypeAnnotation: " + params);
++ }
++ int scale = Integer.parseInt(params.get("scale"));
++ int precision = Integer.parseInt(params.get("precision"));
++ return LogicalTypeAnnotation.decimalType(scale, precision);
++
++ // DATE
++ case "DateLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.dateType();
++
++ // TIME
++ case "TimeLogicalTypeAnnotation":
++ if (!params.containsKey("isAdjustedToUTC") || !params.containsKey("unit")) {
++ throw new IllegalArgumentException(
++ "Missing required parameters for TimeLogicalTypeAnnotation: " + params);
++ }
++
++ boolean isUTC = Boolean.parseBoolean(params.get("isAdjustedToUTC"));
++ String timeUnitStr = params.get("unit");
++
++ LogicalTypeAnnotation.TimeUnit timeUnit;
++ switch (timeUnitStr) {
++ case "MILLIS":
++ timeUnit = LogicalTypeAnnotation.TimeUnit.MILLIS;
++ break;
++ case "MICROS":
++ timeUnit = LogicalTypeAnnotation.TimeUnit.MICROS;
++ break;
++ case "NANOS":
++ timeUnit = LogicalTypeAnnotation.TimeUnit.NANOS;
++ break;
++ default:
++ throw new IllegalArgumentException("Unknown time unit: " + timeUnitStr);
++ }
++ return LogicalTypeAnnotation.timeType(isUTC, timeUnit);
++
++ // TIMESTAMP
++ case "TimestampLogicalTypeAnnotation":
++ if (!params.containsKey("isAdjustedToUTC") || !params.containsKey("unit")) {
++ throw new IllegalArgumentException(
++ "Missing required parameters for TimestampLogicalTypeAnnotation: " + params);
++ }
++ boolean isAdjustedToUTC = Boolean.parseBoolean(params.get("isAdjustedToUTC"));
++ String unitStr = params.get("unit");
++
++ LogicalTypeAnnotation.TimeUnit unit;
++ switch (unitStr) {
++ case "MILLIS":
++ unit = LogicalTypeAnnotation.TimeUnit.MILLIS;
++ break;
++ case "MICROS":
++ unit = LogicalTypeAnnotation.TimeUnit.MICROS;
++ break;
++ case "NANOS":
++ unit = LogicalTypeAnnotation.TimeUnit.NANOS;
++ break;
++ default:
++ throw new IllegalArgumentException("Unknown timestamp unit: " + unitStr);
++ }
++ return LogicalTypeAnnotation.timestampType(isAdjustedToUTC, unit);
++
++ // INTEGER
++ case "IntLogicalTypeAnnotation":
++ if (!params.containsKey("isSigned") || !params.containsKey("bitWidth")) {
++ throw new IllegalArgumentException(
++ "Missing required parameters for IntLogicalTypeAnnotation: " + params);
++ }
++ boolean isSigned = Boolean.parseBoolean(params.get("isSigned"));
++ int bitWidth = Integer.parseInt(params.get("bitWidth"));
++ return LogicalTypeAnnotation.intType(bitWidth, isSigned);
++
++ // JSON
++ case "JsonLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.jsonType();
++
++ // BSON
++ case "BsonLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.bsonType();
++
++ // UUID
++ case "UUIDLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.uuidType();
++
++ // INTERVAL
++ case "IntervalLogicalTypeAnnotation":
++ return LogicalTypeAnnotation.IntervalLogicalTypeAnnotation.getInstance();
++
++ default:
++ throw new IllegalArgumentException("Unknown logical type: " + logicalTypeName);
++ }
++ }
++}
+diff --git a/parquet/src/main/java/org/apache/iceberg/parquet/CometVectorizedParquetReader.java b/parquet/src/main/java/org/apache/iceberg/parquet/CometVectorizedParquetReader.java
+new file mode 100644
+index 0000000..88b195b
+--- /dev/null
++++ b/parquet/src/main/java/org/apache/iceberg/parquet/CometVectorizedParquetReader.java
+@@ -0,0 +1,255 @@
++/*
++ * 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.iceberg.parquet;
++
++import java.io.IOException;
++import java.io.UncheckedIOException;
++import java.nio.ByteBuffer;
++import java.util.List;
++import java.util.Map;
++import java.util.NoSuchElementException;
++import java.util.function.Function;
++import org.apache.comet.parquet.FileReader;
++import org.apache.comet.parquet.ParquetColumnSpec;
++import org.apache.comet.parquet.ReadOptions;
++import org.apache.comet.parquet.RowGroupReader;
++import org.apache.comet.parquet.WrappedInputFile;
++import org.apache.hadoop.conf.Configuration;
++import org.apache.iceberg.Schema;
++import org.apache.iceberg.exceptions.RuntimeIOException;
++import org.apache.iceberg.expressions.Expression;
++import org.apache.iceberg.expressions.Expressions;
++import org.apache.iceberg.io.CloseableGroup;
++import org.apache.iceberg.io.CloseableIterable;
++import org.apache.iceberg.io.CloseableIterator;
++import org.apache.iceberg.io.InputFile;
++import org.apache.iceberg.mapping.NameMapping;
++import org.apache.iceberg.relocated.com.google.common.collect.Lists;
++import org.apache.iceberg.util.ByteBuffers;
++import org.apache.parquet.ParquetReadOptions;
++import org.apache.parquet.column.ColumnDescriptor;
++import org.apache.parquet.hadoop.metadata.ColumnChunkMetaData;
++import org.apache.parquet.hadoop.metadata.ColumnPath;
++import org.apache.parquet.schema.MessageType;
++
++public class CometVectorizedParquetReader<T> extends CloseableGroup
++ implements CloseableIterable<T> {
++ private final InputFile input;
++ private final ParquetReadOptions options;
++ private final Schema expectedSchema;
++ private final Function<MessageType, VectorizedReader<?>> batchReaderFunc;
++ private final Expression filter;
++ private final boolean reuseContainers;
++ private final boolean caseSensitive;
++ private final int batchSize;
++ private final NameMapping nameMapping;
++ private final Map<String, String> properties;
++ private Long start = null;
++ private Long length = null;
++ private ByteBuffer fileEncryptionKey = null;
++ private ByteBuffer fileAADPrefix = null;
++
++ public CometVectorizedParquetReader(
++ InputFile input,
++ Schema expectedSchema,
++ ParquetReadOptions options,
++ Function<MessageType, VectorizedReader<?>> readerFunc,
++ NameMapping nameMapping,
++ Expression filter,
++ boolean reuseContainers,
++ boolean caseSensitive,
++ int maxRecordsPerBatch,
++ Map<String, String> properties,
++ Long start,
++ Long length,
++ ByteBuffer fileEncryptionKey,
++ ByteBuffer fileAADPrefix) {
++ this.input = input;
++ this.expectedSchema = expectedSchema;
++ this.options = options;
++ this.batchReaderFunc = readerFunc;
++ // replace alwaysTrue with null to avoid extra work evaluating a trivial filter
++ this.filter = filter == Expressions.alwaysTrue() ? null : filter;
++ this.reuseContainers = reuseContainers;
++ this.caseSensitive = caseSensitive;
++ this.batchSize = maxRecordsPerBatch;
++ this.nameMapping = nameMapping;
++ this.properties = properties;
++ this.start = start;
++ this.length = length;
++ this.fileEncryptionKey = fileEncryptionKey;
++ this.fileAADPrefix = fileAADPrefix;
++ }
++
++ private ReadConf conf = null;
++
++ private ReadConf init() {
++ if (conf == null) {
++ ReadConf readConf =
++ new ReadConf(
++ input,
++ options,
++ expectedSchema,
++ filter,
++ null,
++ batchReaderFunc,
++ nameMapping,
++ reuseContainers,
++ caseSensitive,
++ batchSize);
++ this.conf = readConf.copy();
++ return readConf;
++ }
++ return conf;
++ }
++
++ @Override
++ public CloseableIterator<T> iterator() {
++ FileIterator<T> iter =
++ new FileIterator<>(init(), properties, start, length, fileEncryptionKey, fileAADPrefix);
++ addCloseable(iter);
++ return iter;
++ }
++
++ private static class FileIterator<T> implements CloseableIterator<T> {
++ // private final ParquetFileReader reader;
++ private final boolean[] shouldSkip;
++ private final VectorizedReader<T> model;
++ private final long totalValues;
++ private final int batchSize;
++ private final List<Map<ColumnPath, ColumnChunkMetaData>> columnChunkMetadata;
++ private final boolean reuseContainers;
++ private int nextRowGroup = 0;
++ private long nextRowGroupStart = 0;
++ private long valuesRead = 0;
++ private T last = null;
++ private final FileReader cometReader;
++
++ FileIterator(
++ ReadConf conf,
++ Map<String, String> properties,
++ Long start,
++ Long length,
++ ByteBuffer fileEncryptionKey,
++ ByteBuffer fileAADPrefix) {
++ this.shouldSkip = conf.shouldSkip();
++ this.totalValues = conf.totalValues();
++ this.reuseContainers = conf.reuseContainers();
++ this.model = conf.vectorizedModel();
++ this.batchSize = conf.batchSize();
++ this.model.setBatchSize(this.batchSize);
++ this.columnChunkMetadata = conf.columnChunkMetadataForRowGroups();
++ this.cometReader =
++ newCometReader(
++ conf.file(),
++ conf.projection(),
++ properties,
++ start,
++ length,
++ fileEncryptionKey,
++ fileAADPrefix);
++ }
++
++ private FileReader newCometReader(
++ InputFile file,
++ MessageType projection,
++ Map<String, String> properties,
++ Long start,
++ Long length,
++ ByteBuffer fileEncryptionKey,
++ ByteBuffer fileAADPrefix) {
++ try {
++ ReadOptions cometOptions = ReadOptions.builder(new Configuration()).build();
++
++ FileReader fileReader =
++ new FileReader(
++ new WrappedInputFile(file),
++ cometOptions,
++ properties,
++ start,
++ length,
++ ByteBuffers.toByteArray(fileEncryptionKey),
++ ByteBuffers.toByteArray(fileAADPrefix));
++
++ List<ColumnDescriptor> columnDescriptors = projection.getColumns();
++
++ List<ParquetColumnSpec> specs = Lists.newArrayList();
++
++ for (ColumnDescriptor descriptor : columnDescriptors) {
++ ParquetColumnSpec spec = CometTypeUtils.descriptorToParquetColumnSpec(descriptor);
++ specs.add(spec);
++ }
++
++ fileReader.setRequestedSchemaFromSpecs(specs);
++ return fileReader;
++ } catch (IOException e) {
++ throw new UncheckedIOException("Failed to open Parquet file: " + file.location(), e);
++ }
++ }
++
++ @Override
++ public boolean hasNext() {
++ return valuesRead < totalValues;
++ }
++
++ @Override
++ public T next() {
++ if (!hasNext()) {
++ throw new NoSuchElementException();
++ }
++ if (valuesRead >= nextRowGroupStart) {
++ advance();
++ }
++
++ // batchSize is an integer, so casting to integer is safe
++ int numValuesToRead = (int) Math.min(nextRowGroupStart - valuesRead, batchSize);
++ if (reuseContainers) {
++ this.last = model.read(last, numValuesToRead);
++ } else {
++ this.last = model.read(null, numValuesToRead);
++ }
++ valuesRead += numValuesToRead;
++
++ return last;
++ }
++
++ private void advance() {
++ while (shouldSkip[nextRowGroup]) {
++ nextRowGroup += 1;
++ cometReader.skipNextRowGroup();
++ }
++ RowGroupReader pages;
++ try {
++ pages = cometReader.readNextRowGroup();
++ } catch (IOException e) {
++ throw new RuntimeIOException(e);
++ }
++
++ model.setRowGroupInfo(pages, columnChunkMetadata.get(nextRowGroup));
++ nextRowGroupStart += pages.getRowCount();
++ nextRowGroup += 1;
++ }
++
++ @Override
++ public void close() throws IOException {
++ model.close();
++ cometReader.close();
++ }
++ }
++}
+diff --git a/parquet/src/main/java/org/apache/iceberg/parquet/Parquet.java b/parquet/src/main/java/org/apache/iceberg/parquet/Parquet.java
+<<<<<<< Updated upstream
+index 2c37a52..503dbd6 100644
+=======
+index 2c37a52..3442cfc 100644
+>>>>>>> Stashed changes
Review Comment:
@hsiang-c It looks like a merge conflict in the diff file
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#issuecomment-3082076029
@hsiang-c created https://github.com/apache/datafusion-comet/issues/2033 to track this issue
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "kazuyukitanimura (via GitHub)" <gi...@apache.org>.
kazuyukitanimura commented on code in PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#discussion_r2183864520
##########
dev/diffs/iceberg/1.8.1.diff:
##########
@@ -195,6 +195,100 @@ index e2d2c7a..d23acef 100644
relocate 'org.apache.orc', 'org.apache.iceberg.shaded.org.apache.orc'
relocate 'io.airlift', 'org.apache.iceberg.shaded.io.airlift'
relocate 'org.apache.hc.client5', 'org.apache.iceberg.shaded.org.apache.hc.client5'
+diff --git a/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/ExtensionsTestBase.java b/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/ExtensionsTestBase.java
+index 578845e..9476f19 100644
+--- a/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/ExtensionsTestBase.java
++++ b/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/ExtensionsTestBase.java
+@@ -57,6 +57,8 @@ public abstract class ExtensionsTestBase extends CatalogTestBase {
+ .config("spark.sql.legacy.respectNullabilityInTextDatasetConversion", "true")
+ .config(
+ SQLConf.ADAPTIVE_EXECUTION_ENABLED().key(), String.valueOf(RANDOM.nextBoolean()))
++ .config("spark.plugins", "org.apache.spark.CometPlugin")
Review Comment:
This makes sense but could be error prone. If there is a new test that uses spark session, we miss enabling it.
Wondering if there is a good way to update all spark session at once...
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#issuecomment-3049800502
I see that some tests are failing due to https://github.com/apache/datafusion-comet/issues/1982
```
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 1764.0 failed 1 times, most recent failure: Lost task 0.0 in stage 1764.0 (TID 3312) (localhost executor driver): java.lang.ClassCastException: class org.apache.spark.sql.catalyst.expressions.GenericInternalRow cannot be cast to class org.apache.spark.sql.vectorized.ColumnarBatch (org.apache.spark.sql.catalyst.expressions.GenericInternalRow and org.apache.spark.sql.vectorized.ColumnarBatch are in unnamed module of loader 'app')
```
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: [iceberg] Switch to OSS Spark and run Iceberg Spark tests in parallel [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #1987:
URL: https://github.com/apache/datafusion-comet/pull/1987#discussion_r2260901481
##########
.github/workflows/iceberg_spark_test.yml:
##########
@@ -63,24 +63,96 @@ jobs:
with:
rust-version: ${{env.RUST_VERSION}}
jdk-version: ${{ matrix.java-version }}
+ - name: Build Comet
+ shell: bash
+ run: |
+ PROFILES="-Pspark-${{matrix.spark-version.short}} -Pscala-${{matrix.scala-version}}" make release
- name: Setup Iceberg
uses: ./.github/actions/setup-iceberg-builder
with:
iceberg-version: ${{ matrix.iceberg-version.full }}
- scala-version: ${{ matrix.scala-version }}
- spark-short-version: ${{ matrix.spark-version.short }}
- - name: Build local Spark jar with comet patch
- uses: ./.github/actions/setup-spark-local-jar
- with:
- spark-short-version: ${{ matrix.spark-version.short }}
- spark-version: ${{ matrix.spark-version.full }}
- scala-version: ${{ matrix.scala-version }}
- name: Run Iceberg Spark tests
run: |
cd apache-iceberg
rm -rf /root/.m2/repository/org/apache/parquet # somehow parquet cache requires cleanups
- ENABLE_COMET=true ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
- :iceberg-spark:iceberg-spark-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:check \
- :iceberg-spark:iceberg-spark-extensions-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:check \
- :iceberg-spark:iceberg-spark-runtime-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:check \
+ ENABLE_COMET=true COMET_PARQUET_SCAN_IMPL=native_iceberg_compat ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
+ :iceberg-spark:iceberg-spark-${{ matrix.spark-version.short }}_${{ matrix.scala-version }}:test \
-Pquick=true -x javadoc
+
+ iceberg-spark-extensions:
+ if: contains(github.event.pull_request.title, '[iceberg]')
+ strategy:
+ matrix:
+ os: [ubuntu-24.04]
+ java-version: [11, 17]
+ iceberg-version: [{short: '1.8', full: '1.8.1'}]
+ spark-version: [{short: '3.5', full: '3.5.6'}]
+ scala-version: ['2.13']
+ fail-fast: false
+ name: iceberg-spark-extensions/${{ matrix.os }}/iceberg-${{ matrix.iceberg-version.full }}/spark-${{ matrix.spark-version.full }}/scala-${{ matrix.scala-version }}/java-${{ matrix.java-version }}
+ runs-on: ${{ matrix.os }}
+ container:
+ image: amd64/rust
+ env:
+ SPARK_LOCAL_IP: localhost
+ steps:
+ - uses: actions/checkout@v4
+ - name: Setup Rust & Java toolchain
+ uses: ./.github/actions/setup-builder
+ with:
+ rust-version: ${{env.RUST_VERSION}}
+ jdk-version: ${{ matrix.java-version }}
+ - name: Build Comet
+ shell: bash
+ run: |
+ PROFILES="-Pspark-${{matrix.spark-version.short}} -Pscala-${{matrix.scala-version}}" make release
+ - name: Setup Iceberg
+ uses: ./.github/actions/setup-iceberg-builder
+ with:
+ iceberg-version: ${{ matrix.iceberg-version.full }}
+ - name: Run Iceberg Spark extensions tests
+ run: |
+ cd apache-iceberg
+ rm -rf /root/.m2/repository/org/apache/parquet # somehow parquet cache requires cleanups
+ ENABLE_COMET=true COMET_PARQUET_SCAN_IMPL=native_iceberg_compat ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
Review Comment:
Same commet as above.
```suggestion
ENABLE_COMET=true ./gradlew -DsparkVersions=${{ matrix.spark-version.short }} -DscalaVersion=${{ matrix.scala-version }} -DflinkVersions= -DkafkaVersions= \
```
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org