Skip to content

[GLUTEN-12698][CORE] Add Iceberg read/write offload switches - #12699

Merged
jackylee-ch merged 3 commits into
apache:mainfrom
jackylee-ch:iceberg-offload-switch
Aug 11, 2026
Merged

[GLUTEN-12698][CORE] Add Iceberg read/write offload switches#12699
jackylee-ch merged 3 commits into
apache:mainfrom
jackylee-ch:iceberg-offload-switch

Conversation

@jackylee-ch

@jackylee-ch jackylee-ch commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

Gluten has no Iceberg-specific config today. Disabling Iceberg offload means using a much broader
switch: spark.gluten.sql.columnar.batchscan for reads (also falls back Paimon/Hudi and all other
batch scans), and spark.gluten.sql.enable.enhancedFeatures for writes (a bundled flag).

Add two backend-agnostic switches, both defaulting to true so behaviour is unchanged:

spark.gluten.sql.columnar.iceberg.enableNativeRead
spark.gluten.sql.columnar.iceberg.enableNativeWrite

They live in gluten-iceberg rather than a backend module, since OffloadIcebergScan is shared by
the Velox and ClickHouse components and a backend later gaining Iceberg write should reuse the same
key. Both are checked inside the offload rules rather than at rule-injection time, so they stay
modifiable per session. The write switch is AND-ed with enhancedFeatures rather than replacing it.

How was this patch tested?

Newly added tests.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude claude-opus-5

Related issue: #12698

Gluten had no Iceberg-specific configuration entry. Disabling Iceberg offload
meant reaching for a much broader switch: `spark.gluten.sql.columnar.batchscan`
for reads, which also falls back Paimon, Hudi and every other batch scan, and
`spark.gluten.sql.enable.enhancedFeatures` for writes, a bundled flag documented
as covering "iceberg native write and other features".

Add two backend-agnostic switches, both defaulting to true so behaviour is
unchanged:

  spark.gluten.sql.columnar.iceberg.enableNativeRead
  spark.gluten.sql.columnar.iceberg.enableNativeWrite

They live in `gluten-iceberg` rather than a backend module because
`OffloadIcebergScan` is shared by the Velox and ClickHouse components, and a
backend that later gains Iceberg write support should honour the same write key
instead of adding its own.

Both are checked inside the offload rules rather than at rule-injection time, so
they stay modifiable per session. The write switch is AND-ed with the existing
`enhancedFeatures` gate rather than replacing it.

Fixes apache#12698
Copilot AI lite review requested due to automatic review settings August 5, 2026 08:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@jackylee-ch

Copy link
Copy Markdown
Contributor Author

cc @jinchengchenghh PTAL

@infvg infvg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, just a few nits

Drop the `OffloadIcebergScanBase` / `OffloadIcebergWriteBase` traits and inline the
config check into each offload rule, following the existing `OffloadDeltaCommand`
precedent. The traits existed only as an injection point for the unit suites.

Remove `OffloadIcebergScanSuite`, `OffloadIcebergWriteSuite` and
`GlutenIcebergConfigSuite`. The switches are already covered end to end by the
integration tests added to `IcebergSuite` and `VeloxIcebergSuite` in this PR.
Copilot AI review requested due to automatic review settings August 5, 2026 18:02
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (2)

gluten-iceberg/src/test/scala/org/apache/gluten/execution/IcebergSuite.scala:762

  • This test checks only that IcebergScanTransformer is absent, but that still allows other BatchScanExec-based Gluten transformers to run. To validate the switch truly forces a Spark fallback for Iceberg, it helps to assert the executed plan contains no BatchScanExecTransformerBase for the Iceberg query.
            val icebergDf = spark.sql("select * from iceberg_read_switch_tb")
            assert(
              !getExecutedPlan(icebergDf).exists(_.isInstanceOf[IcebergScanTransformer]),
              "Iceberg scan should fall back")

gluten-iceberg/src/test/scala/org/apache/gluten/execution/IcebergSuite.scala:736

  • checkSparkPlan[BatchScanExec] is not sufficient to prove the query actually fell back to vanilla Spark, because Gluten batch-scan transformers (including IcebergScanTransformer) are also BatchScanExec subclasses. This can make the test pass even if the scan is still being offloaded via another BatchScanExec-based transformer. Consider asserting that no BatchScanExecTransformerBase appears in the executed plan (and optionally that a vanilla BatchScanExec does).

This issue also appears on line 759 of the same file.

        val df = spark.sql("select * from iceberg_read_switch_tb")
        checkSparkPlan[BatchScanExec](df)
        assert(
          !getExecutedPlan(df).exists(_.isInstanceOf[IcebergScanTransformer]),
          "Iceberg scan should not be offloaded when native read is disabled")

Comment thread gluten-iceberg/src/main/scala/org/apache/gluten/config/GlutenIcebergConfig.scala Outdated
Comment thread gluten-iceberg/src/test/scala/org/apache/gluten/execution/IcebergSuite.scala Outdated
Copilot AI review requested due to automatic review settings August 6, 2026 02:25
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@jackylee-ch

Copy link
Copy Markdown
Contributor Author

cc @infvg @jinchengchenghh PTAL

@infvg infvg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jackylee-ch

Copy link
Copy Markdown
Contributor Author

@jinchengchenghh Any more questions?
also cc @zhouyuan

@zhouyuan

Copy link
Copy Markdown
Member

@jackylee-ch thanks for the patch, initially we have a config to control the write behavior, could you please help to remove this as well?
spark.gluten.sql.columnar.appendData

| spark.gluten.sql.columnar.appendData | 🔄 Dynamic | true | Enable or disable columnar v2 command append data. |

@jackylee-ch

Copy link
Copy Markdown
Contributor Author

I did notice that we still have several plan-level configurations, for example:

  • spark.gluten.sql.columnar.appendData
  • spark.gluten.sql.columnar.replaceData
  • spark.gluten.sql.columnar.overwriteByExpression
  • spark.gluten.sql.columnar.overwritePartitionsDynamic
  • spark.gluten.sql.columnar.writeToDataSourceV2

My understanding is that these options are mainly used to control fallback for specific plans or write paths, rather than enabling or disabling a generic capability.

Considering that Gluten may support more table/file formats in the future, I think these plan-level switches can still be useful as fine-grained fallback controls, especially when support varies across formats or backends. Therefore, I prefer to keep them as-is for now rather than consolidating or removing them as part of this change.

@zhouyuan

Copy link
Copy Markdown
Member

@jackylee-ch could you please clarify whether there is a defined priority between these two sets of configurations? We may need to define a similar configuration for Delta Cc: @zhztheplayer @malinjawi

@jackylee-ch

Copy link
Copy Markdown
Contributor Author

@jackylee-ch could you please clarify whether there is a defined priority between these two sets of configurations?

The enableNativeWrite only takes effect when plan-level configs are true, but they're ANDed — no priority.

@zhouyuan zhouyuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jackylee-ch
jackylee-ch merged commit ca82b77 into apache:main Aug 11, 2026
183 of 192 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants