Skip to content

[GLUTEN-12597][CORE] Migrate Substrait extension referencing from URI to URN - #12604

Merged
zhouyuan merged 1 commit into
apache:mainfrom
nielspardon:feat/substrait-0.98-inc1-uri-to-urn
Jul 27, 2026
Merged

[GLUTEN-12597][CORE] Migrate Substrait extension referencing from URI to URN#12604
zhouyuan merged 1 commit into
apache:mainfrom
nielspardon:feat/substrait-0.98-inc1-uri-to-urn

Conversation

@nielspardon

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

Second increment of the Substrait 0.98 proto rebase (#12597). Stacked on #12598 (approved, not yet merged) — until #12598 lands, this PR's diff includes its commit; the change owned by this PR is the top commit (URI→URN). I'll rebase onto main once #12598 merges, which reduces the diff to just this increment. (The two increments touch disjoint files.)

Adopts the 0.98 URN-based simple-extension referencing model (substrait-io/substrait#971), replacing URI-based references with URNs of the form extension:<OWNER>:<ID>:

  • extensions.proto: SimpleExtensionURISimpleExtensionURN; extension_uri_anchorextension_urn_anchor; uriurn; and in ExtensionType / ExtensionTypeVariation / ExtensionFunction, extension_uri_reference (field 1) is reserved and replaced by extension_urn_reference (field 4).
  • plan.proto / extended_expression.proto: extension_uris (field 1) reserved, replaced by extension_urns = 8 (repeated SimpleExtensionURN).
  • Velox producer (SubstraitExtensionCollector, VeloxToSubstraitPlan): now emit extension_urns / extension_urn_reference. Gluten maps all functions to a single catch-all anchor and resolves them by name, so it emits one valid-format placeholder URN extension:org.apache.gluten:functions instead of an empty string; consuming the real upstream io.substrait function-extension URNs is a follow-up. Gluten's JVM producer never emitted extension_uris, so it needs no changes beyond recompiling against the regenerated classes.
  • Velox test fixtures: updated to URN field names and proper spec URN values (extension:io.substrait:<file>).

AdvancedExtension.optimization (also repeated in 0.98) and the additive Plan fields (parameter_bindings / type_aliases / execution_behavior) are handled in follow-up increments.

How was this patch tested?

No behavioral change — this is a referencing-mechanism migration. Verified locally: the vendored proto compiles (protoc); the gluten-substrait JVM build succeeds (regenerating the SimpleExtensionURN classes); and the Velox native library builds (libgluten / libvelox, recompiling SubstraitExtensionCollector / VeloxToSubstraitPlan / SubstraitParser against the regenerated proto). The ClickHouse backend has no extension_uri* references and is unaffected. Existing Velox conversion tests exercise the updated fixtures.

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

Generated-by: Claude Code (Claude Opus 4.8)

🤖 Generated with AI

@github-actions github-actions Bot added CORE works for Gluten Core VELOX labels Jul 23, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

… to URN

Adopt the 0.98 URN-based simple-extension referencing model (substrait-io/substrait#971):
- extensions.proto: SimpleExtensionURI -> SimpleExtensionURN; extension_uri_anchor -> extension_urn_anchor; uri -> urn; and in ExtensionType/ExtensionTypeVariation/ExtensionFunction, extension_uri_reference (field 1) is reserved and replaced by extension_urn_reference (field 4).
- plan.proto / extended_expression.proto: extension_uris (field 1) is reserved, replaced by extension_urns = 8 (repeated SimpleExtensionURN).

Velox producer (SubstraitExtensionCollector, VeloxToSubstraitPlan) now emits extension_urns / extension_urn_reference. Gluten still maps every function to one catch-all anchor and resolves by name, so the emitted URN is a single placeholder in the required extension:<OWNER>:<ID> format (extension:org.apache.gluten:functions) rather than an empty string; consuming the upstream io.substrait function extensions is a follow-up. Gluten's JVM producer never emitted extension_uris, so it needs no changes beyond recompiling against the regenerated classes. Test fixtures updated to URN field names and proper spec URN values (extension:io.substrait:<file>).

AdvancedExtension.optimization (also repeated in 0.98) and the additive Plan fields (parameter_bindings/type_aliases/execution_behavior) are handled in follow-up increments. Part of apache#12597.

Validated locally: gluten-substrait JVM build + Velox native build (libgluten/libvelox).
@nielspardon
nielspardon force-pushed the feat/substrait-0.98-inc1-uri-to-urn branch from 4e261ff to 9f0fa46 Compare July 23, 2026 14:25
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@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.

LGTM, thanks for the fix @nielspardon !

@zhouyuan
zhouyuan merged commit 152ec52 into apache:main Jul 27, 2026
55 checks passed
nielspardon added a commit to nielspardon/gluten that referenced this pull request Jul 28, 2026
Substrait 0.98 changed extensions.proto AdvancedExtension.optimization from a singular to a repeated google.protobuf.Any (substrait-io/substrait). Update all producers and consumers accordingly:
- Producers: AdvancedExtensionNode (JVM) and CHFormatWriterInjects use addOptimization(...) instead of setOptimization(...); VeloxToSubstraitPlan uses add_optimization() instead of mutable_optimization().
- Consumers: has_optimization() -> optimization_size() > 0 and optimization() -> optimization(0) in the Velox SubstraitParser / SubstraitToVeloxPlan and in the ClickHouse RelParsers (Read/Cross/Aggregate/Join/GroupLimit/Write) and local_engine_jni.

The old singular optimization() accessor returned a default-constructed Any when unset, so consumers could read optimization().value()/UnpackTo() unconditionally. optimization(0) on an empty repeated field is out-of-bounds and crashes. The Velox reads are all guarded by optimization_size() > 0; the ClickHouse reads relied on that null-safe behavior, so route them through a firstOptimizationOrDefault() helper (SubstraitParserUtils.h) that returns Any::default_instance() when no optimization is present, preserving the prior semantics.

Validated locally: proto (protoc), gluten-substrait JVM build, and Velox native build (libgluten/libvelox). The ClickHouse native parsers are covered by CI (local libch build requires a Linux/Docker toolchain). Part of apache#12597.

Depends on apache#12604 (URI->URN).
zhouyuan pushed a commit that referenced this pull request Jul 29, 2026
…2642)

Substrait 0.98 changed extensions.proto AdvancedExtension.optimization from a singular to a repeated google.protobuf.Any (substrait-io/substrait). Update all producers and consumers accordingly:
- Producers: AdvancedExtensionNode (JVM) and CHFormatWriterInjects use addOptimization(...) instead of setOptimization(...); VeloxToSubstraitPlan uses add_optimization() instead of mutable_optimization().
- Consumers: has_optimization() -> optimization_size() > 0 and optimization() -> optimization(0) in the Velox SubstraitParser / SubstraitToVeloxPlan and in the ClickHouse RelParsers (Read/Cross/Aggregate/Join/GroupLimit/Write) and local_engine_jni.

The old singular optimization() accessor returned a default-constructed Any when unset, so consumers could read optimization().value()/UnpackTo() unconditionally. optimization(0) on an empty repeated field is out-of-bounds and crashes. The Velox reads are all guarded by optimization_size() > 0; the ClickHouse reads relied on that null-safe behavior, so route them through a firstOptimizationOrDefault() helper (SubstraitParserUtils.h) that returns Any::default_instance() when no optimization is present, preserving the prior semantics.

Validated locally: proto (protoc), gluten-substrait JVM build, and Velox native build (libgluten/libvelox). The ClickHouse native parsers are covered by CI (local libch build requires a Linux/Docker toolchain). Part of #12597.

Depends on #12604 (URI->URN).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core VELOX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants