You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/10/21 11:08:30 UTC
(datafusion-comet) branch gh-readonly-queue/main/pr-7132-74392a9427db2cdae9ba9a2a710985cce945e0f7 created (now 38d392940e)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-7132-74392a9427db2cdae9ba9a2a710985cce945e0f7
in repository https://gitbox.apache.org/repos/asf/datafusion-comet.git
at 38d392940e perf: default the native Iceberg scan to two concurrent data files (#7132)
This branch includes the following new commits:
new 38d392940e perf: default the native Iceberg scan to two concurrent data files (#7132)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org
(datafusion-comet) 01/01: perf: default the native Iceberg scan to two concurrent data files (#7132)
Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-7132-74392a9427db2cdae9ba9a2a710985cce945e0f7
in repository https://gitbox.apache.org/repos/asf/datafusion-comet.git
commit 38d392940efeb8557c0cf4c17bc887640028d5b2
Author: Andy Grove <ag...@apache.org>
AuthorDate: Wed Oct 21 11:08:06 2026 +0000
perf: default the native Iceberg scan to two concurrent data files (#7132)
* perf: default the native Iceberg scan to two concurrent data files
Default spark.comet.scan.icebergNative.dataFileConcurrencyLimit to 2 so a task overlaps the open of two data files. The default is read through COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT, which the Iceberg Spark test jobs and dev/local-ci.sh set to 1 because Iceberg's tests expect file order from queries without an ORDER BY.
* test: keep file read order in Iceberg tests that depend on it
---
.github/workflows/iceberg_spark_test_reusable.yml | 6 +++---
dev/local-ci.sh | 2 ++
docs/source/contributor-guide/iceberg-spark-tests.md | 8 +++++++-
docs/source/user-guide/latest/iceberg.md | 19 ++++++++++++++-----
docs/source/user-guide/latest/migration-guide.md | 10 ++++++++++
spark/src/main/scala/org/apache/comet/CometConf.scala | 14 ++++++++++----
.../sql-tests/iceberg/metadata_column_partition.sql | 2 +-
.../org/apache/comet/CometFuzzIcebergSuite.scala | 10 +++++++---
.../apache/comet/CometIcebergWriteActionSuite.scala | 9 ++++++---
9 files changed, 60 insertions(+), 20 deletions(-)
diff --git a/.github/workflows/iceberg_spark_test_reusable.yml b/.github/workflows/iceberg_spark_test_reusable.yml
index 4154c6feb5..faa7ae610e 100644
--- a/.github/workflows/iceberg_spark_test_reusable.yml
+++ b/.github/workflows/iceberg_spark_test_reusable.yml
@@ -155,7 +155,7 @@ jobs:
rm -rf /root/.m2/repository/org/apache/parquet # somehow parquet cache requires cleanups
# COMET_ICEBERG_WRITE_REPORT_DIR records which writer ran each Iceberg
# write; see dev/ci/summarize-iceberg-writes.py.
- ENABLE_COMET=true ENABLE_COMET_ONHEAP=true COMET_ICEBERG_WRITE_REPORT_DIR="$PWD/build/comet-iceberg-writes" \
+ ENABLE_COMET=true ENABLE_COMET_ONHEAP=true COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT=1 COMET_ICEBERG_WRITE_REPORT_DIR="$PWD/build/comet-iceberg-writes" \
./gradlew -DsparkVersions=${{ inputs.spark-short }} -DscalaVersion=${{ inputs.scala }} -DflinkVersions= -DkafkaVersions= \
:iceberg-spark:iceberg-spark-${{ inputs.spark-short }}_${{ inputs.scala }}:test \
--init-script ../dev/ci/iceberg-test-shards.gradle \
@@ -235,7 +235,7 @@ jobs:
run: |
cd apache-iceberg
rm -rf /root/.m2/repository/org/apache/parquet # somehow parquet cache requires cleanups
- ENABLE_COMET=true ENABLE_COMET_ONHEAP=true COMET_ICEBERG_WRITE_REPORT_DIR="$PWD/build/comet-iceberg-writes" \
+ ENABLE_COMET=true ENABLE_COMET_ONHEAP=true COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT=1 COMET_ICEBERG_WRITE_REPORT_DIR="$PWD/build/comet-iceberg-writes" \
./gradlew -DsparkVersions=${{ inputs.spark-short }} -DscalaVersion=${{ inputs.scala }} -DflinkVersions= -DkafkaVersions= \
:iceberg-spark:iceberg-spark-extensions-${{ inputs.spark-short }}_${{ inputs.scala }}:test \
-Pquick=true -x javadoc
@@ -286,6 +286,6 @@ jobs:
run: |
cd apache-iceberg
rm -rf /root/.m2/repository/org/apache/parquet # somehow parquet cache requires cleanups
- ENABLE_COMET=true ENABLE_COMET_ONHEAP=true ./gradlew -DsparkVersions=${{ inputs.spark-short }} -DscalaVersion=${{ inputs.scala }} -DflinkVersions= -DkafkaVersions= \
+ ENABLE_COMET=true ENABLE_COMET_ONHEAP=true COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT=1 ./gradlew -DsparkVersions=${{ inputs.spark-short }} -DscalaVersion=${{ inputs.scala }} -DflinkVersions= -DkafkaVersions= \
:iceberg-spark:iceberg-spark-runtime-${{ inputs.spark-short }}_${{ inputs.scala }}:integrationTest \
-Pquick=true -x javadoc
diff --git a/dev/local-ci.sh b/dev/local-ci.sh
index 853108aeef..b7d07f6b41 100755
--- a/dev/local-ci.sh
+++ b/dev/local-ci.sh
@@ -405,6 +405,8 @@ gradlew() {
cd "$dest"
# shellcheck disable=SC2031
export SPARK_LOCAL_IP=localhost ENABLE_COMET=true ENABLE_COMET_ONHEAP=true
+ # Iceberg's tests expect file order from queries without an ORDER BY.
+ export COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT=1
# One directory per target, emptied first, so a rerun reports only its own writes.
export COMET_ICEBERG_WRITE_REPORT_DIR="$dest/build/comet-iceberg-writes/$target"
rm -rf "$COMET_ICEBERG_WRITE_REPORT_DIR"
diff --git a/docs/source/contributor-guide/iceberg-spark-tests.md b/docs/source/contributor-guide/iceberg-spark-tests.md
index e0cdccd7ee..9e35a82881 100644
--- a/docs/source/contributor-guide/iceberg-spark-tests.md
+++ b/docs/source/contributor-guide/iceberg-spark-tests.md
@@ -86,11 +86,17 @@ git apply ../datafusion-comet/dev/diffs/iceberg/1.8.1.diff
## 3. Run Iceberg Spark Tests
```shell
-ENABLE_COMET=true ./gradlew -DsparkVersions=3.5 -DscalaVersion=2.13 -DflinkVersions= -DkafkaVersions= \
+ENABLE_COMET=true COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT=1 \
+ ./gradlew -DsparkVersions=3.5 -DscalaVersion=2.13 -DflinkVersions= -DkafkaVersions= \
:iceberg-spark:iceberg-spark-3.5_2.13:test \
-Pquick=true -x javadoc
```
+`COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT=1` is the environment variable behind
+`spark.comet.scan.icebergNative.dataFileConcurrencyLimit`, which defaults to 2. Iceberg's tests expect
+file order from queries without an `ORDER BY`, and a limit above 1 returns batches from different files
+in no particular order, so the CI jobs and `dev/local-ci.sh` pin it to 1.
+
The three Gradle targets tested in CI are:
| Gradle Target | What It Covers |
diff --git a/docs/source/user-guide/latest/iceberg.md b/docs/source/user-guide/latest/iceberg.md
index 7f251a2c2d..972ceea6fb 100644
--- a/docs/source/user-guide/latest/iceberg.md
+++ b/docs/source/user-guide/latest/iceberg.md
@@ -63,11 +63,20 @@ Catalog configuration is standard Iceberg-on-Spark and independent of Comet. The
### Tuning
-Comet’s native Iceberg reader supports fetching multiple files in parallel to hide I/O latency with the
-config `spark.comet.scan.icebergNative.dataFileConcurrencyLimit`. This value defaults to 1 to
-maintain test behavior on Iceberg Java tests without `ORDER BY` clauses, but we suggest increasing it to
-values between 2 and 8 based on your workload, at the cost of extra memory. This helps most for
-tables with many small files or high-latency storage.
+Comet’s native Iceberg reader fetches multiple data files in parallel to hide I/O latency. The config
+`spark.comet.scan.icebergNative.dataFileConcurrencyLimit` sets how many files one task reads at a time.
+It defaults to 2, which helps most for tables with many small files or high-latency storage such as S3.
+Values between 2 and 8 are reasonable; raise it based on your workload, at the cost of extra memory,
+because each file in flight holds its own buffers.
+
+When the limit is above 1, batches from different files are returned in no particular order, so a
+query without an `ORDER BY` can return rows in a different order than with a limit of 1. Spark does
+not guarantee that order, but some tests and applications depend on it. Set the limit to `1` to read
+the files one after another, in the order Spark assigned them.
+
+The Iceberg Spark tests are an example. They expect file order from queries without an `ORDER BY`, so
+the Iceberg test jobs set the environment variable `COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT=1`,
+which overrides the default. See [Iceberg Spark tests](../../contributor-guide/iceberg-spark-tests.md).
### Supported features
diff --git a/docs/source/user-guide/latest/migration-guide.md b/docs/source/user-guide/latest/migration-guide.md
index d48cc11683..9861eac54f 100644
--- a/docs/source/user-guide/latest/migration-guide.md
+++ b/docs/source/user-guide/latest/migration-guide.md
@@ -107,6 +107,16 @@ that still sets it to `true` keeps the split plan, with iceberg-java writing the
on Spark 3.5+ it now also plans merge-on-read writes as the split plan. Unset it to plan Spark's
own operator.
+### Native Iceberg Scan File Concurrency
+
+`spark.comet.scan.icebergNative.dataFileConcurrencyLimit` now defaults to 2, where Comet `1.1.0`
+defaulted to 1. The native Iceberg scan reads two data files at once within a task, which hides the
+latency of opening each file on tables with many small files or on high-latency storage such as S3.
+Each file in flight holds its own buffers, so a task can use more off-heap memory, and a query
+without an `ORDER BY` can return rows in a different order than before, because batches from the two
+files interleave. Spark does not guarantee the order of such a result. To read one file at a time in
+the order Spark assigned them, as before, set the setting to `1`. See [Iceberg tuning](iceberg.md#tuning).
+
## Upgrading to Comet 1.1.0
Comet `1.1.0` makes no behavior changes that need a `spark.comet.legacy.*` key. The changes below
diff --git a/spark/src/main/scala/org/apache/comet/CometConf.scala b/spark/src/main/scala/org/apache/comet/CometConf.scala
index 260dccadfc..081161a7f1 100644
--- a/spark/src/main/scala/org/apache/comet/CometConf.scala
+++ b/spark/src/main/scala/org/apache/comet/CometConf.scala
@@ -148,12 +148,18 @@ object CometConf extends ShimCometConf {
conf("spark.comet.scan.icebergNative.dataFileConcurrencyLimit")
.category(CATEGORY_SCAN)
.doc(
- "The number of Iceberg data files to read concurrently within a single task. " +
- "Higher values improve throughput for tables with many small files by overlapping " +
- "I/O latency, but increase memory usage. Values between 2 and 8 are suggested.")
+ "The number of Iceberg data files the native Iceberg scan reads concurrently within " +
+ "a single task. Reading several files at once overlaps the latency of opening each " +
+ "one, which speeds up tables with many small files and high-latency storage such as " +
+ "S3, but each file in flight holds its own buffers, so memory use grows with the " +
+ "limit. When it is above 1, the scan returns batches from different files in no " +
+ "particular order, so rows can come back in a different order than with 1. Set it " +
+ "to 1 to read the files one after another, in the order Spark assigned them. The " +
+ "Iceberg Spark test jobs pin it to 1 through the environment variable, because " +
+ "Iceberg's tests expect file order from queries without an ORDER BY.")
.intConf
.checkValue(v => v > 0, "Data file concurrency limit must be positive")
- .createWithDefault(1)
+ .createWithEnvVarOrDefault("COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT", 2)
val COMET_ICEBERG_NESTED_SCHEMA_PRUNING_ENABLED: ConfigEntry[Boolean] =
conf("spark.comet.scan.icebergNative.nestedSchemaPruning.enabled")
diff --git a/spark/src/test/resources/sql-tests/iceberg/metadata_column_partition.sql b/spark/src/test/resources/sql-tests/iceberg/metadata_column_partition.sql
index 9ceda6bb8e..b2f7b5be61 100644
--- a/spark/src/test/resources/sql-tests/iceberg/metadata_column_partition.sql
+++ b/spark/src/test/resources/sql-tests/iceberg/metadata_column_partition.sql
@@ -257,7 +257,7 @@ statement
INSERT INTO test_cat.db.multi_rg SELECT id, REPEAT('x', 100) FROM range(1000)
query
-SELECT _pos, id FROM test_cat.db.multi_rg WHERE _pos IN (0, 1, 998, 999) ORDER BY _pos
+SELECT _pos, id FROM test_cat.db.multi_rg WHERE _pos IN (0, 1, 998, 999) ORDER BY _pos, id
statement
DROP TABLE test_cat.db.multi_rg
diff --git a/spark/src/test/scala/org/apache/comet/CometFuzzIcebergSuite.scala b/spark/src/test/scala/org/apache/comet/CometFuzzIcebergSuite.scala
index 3c42221ea3..ad9bd99b59 100644
--- a/spark/src/test/scala/org/apache/comet/CometFuzzIcebergSuite.scala
+++ b/spark/src/test/scala/org/apache/comet/CometFuzzIcebergSuite.scala
@@ -38,9 +38,13 @@ class CometFuzzIcebergSuite extends CometFuzzIcebergBase {
}
test("select * with limit") {
- val sql = s"SELECT * FROM $icebergTableName LIMIT 500"
- val (_, cometPlan) = checkSparkAnswer(sql)
- assert(1 == collectIcebergNativeScans(cometPlan).length)
+ // Without an ORDER BY, the rows a LIMIT keeps depend on the order the data files are read in,
+ // so read one file at a time to keep that order.
+ withSQLConf(CometConf.COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT.key -> "1") {
+ val sql = s"SELECT * FROM $icebergTableName LIMIT 500"
+ val (_, cometPlan) = checkSparkAnswer(sql)
+ assert(1 == collectIcebergNativeScans(cometPlan).length)
+ }
}
test("order by single column") {
diff --git a/spark/src/test/scala/org/apache/comet/CometIcebergWriteActionSuite.scala b/spark/src/test/scala/org/apache/comet/CometIcebergWriteActionSuite.scala
index 7e307f2a13..a92cfdc208 100644
--- a/spark/src/test/scala/org/apache/comet/CometIcebergWriteActionSuite.scala
+++ b/spark/src/test/scala/org/apache/comet/CometIcebergWriteActionSuite.scala
@@ -4537,9 +4537,12 @@ class CometIcebergWriteActionSuite
assert(paths.size == 8, s"expected one file per partition, got $paths")
assert(paths == paths.sorted, s"fanout data files are not listed in path order: $paths")
- // The manifest order is what an unordered read comes back in, so it is stable too.
- val ids = spark.sql(s"SELECT id FROM $catalog.$ns.fanout_order").collect().toSeq
- assert(ids.map(_.getInt(0)) == (0 until 8), s"unordered read: ${ids.mkString(", ")}")
+ // The manifest order is what an unordered read comes back in, so it is stable too, as long
+ // as the native scan reads one data file at a time.
+ withSQLConf(CometConf.COMET_ICEBERG_DATA_FILE_CONCURRENCY_LIMIT.key -> "1") {
+ val ids = spark.sql(s"SELECT id FROM $catalog.$ns.fanout_order").collect().toSeq
+ assert(ids.map(_.getInt(0)) == (0 until 8), s"unordered read: ${ids.mkString(", ")}")
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org