Skip to content

[DNM][CORE] Replace string-based native conf key lists with declarative NativeConfRegistry#12549

Draft
jackylee-ch wants to merge 2 commits into
apache:mainfrom
jackylee-ch:config-pass-to-native
Draft

[DNM][CORE] Replace string-based native conf key lists with declarative NativeConfRegistry#12549
jackylee-ch wants to merge 2 commits into
apache:mainfrom
jackylee-ch:config-pass-to-native

Conversation

@jackylee-ch

@jackylee-ch jackylee-ch commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

[DNM] Do Not Merge — for design discussion.

This PR fully replaces the hard-coded, string-based native conf key lists in GlutenConfig.getNativeSessionConf / getNativeBackendConf with a declarative registration mechanism, so each module declares its own native confs on demand instead of common code maintaining giant key lists.

The mechanism

  1. NativeConfRegistry (gluten-core): a central registry of conf keys to pass to native side. Session and backend(static) scopes are tracked separately, so the same key can carry different semantics per scope. Each entry supports:

    • defaultToPass: if defined, the key is always passed, using the default value when unset by user (replaces the old "configs having default values" lists);
    • transform: applied to user-set values before passing (replaces the old per-key special cases such as byte-unit conversion for spark.shuffle.file.buffer and upper-casing for spark.sql.legacy.timeParserPolicy).
  2. ConfigBuilder.passToNative(scope) / passToNativeWithDefault(scope, default): Gluten config entries declare native passing right at their definitions, e.g.

val COLUMNAR_MAX_BATCH_SIZE =
  buildConf("spark.gluten.sql.columnar.maxBatchSize")
    .passToNative()   // registered to NativeConfRegistry on creation
    .intConf
    .createWithDefault(4096)

For passToNativeWithDefault, the parsed default is registered (e.g. a bytesConf default "1KB" is passed to native as "1024"), keeping JVM/native value formats consistent.

  1. NativeConfRegistry.registerRaw: for non-Gluten keys (SQLConf / Spark core / Hadoop / S3 / GCS) that have no Gluten ConfigEntry. All such registrations now live in a single registerNativeConfs() in GlutenConfig, and velox-only raw keys are registered from VeloxConfig in backends-velox instead of common code.

What is removed

  • The nativeKeys set (40+ hard-coded strings, including velox-specific keys living in common code) in GlutenConfig.
  • The two "configs having default values" Seqs and all per-key special-case code in getNativeSessionConf / getNativeBackendConf. Both methods now do: registry selection + existing prefix rules + UGI tokens (session only).
  • BackendSettingsApi.extraNativeSessionConfKeys / extraNativeBackendConfKeys (no backend ever overrode them).
  • GlutenConfigUtil.mapByteConfValue (superseded by entry-level transform).

Behavior compatibility

The selected key/value results of getNativeSessionConf / getNativeBackendConf are intended to be identical to before. Notable equivalence mappings:

Old code New declaration
nativeKeys filter .passToNative(SESSION) / registerRaw(key, SESSION)
session default-value Seq .passToNativeWithDefault(SESSION) / registerRaw(..., defaultToPass)
mapByteConfValue special cases registerRaw(..., transform = byte conversion)
timeParserPolicy.toUpperCase registerRaw(..., transform = upper-case)
backend default-value Seq .passToNativeWithDefault(BACKEND, ...) / registerRaw(..., BACKEND, defaultToPass)
backend keys filter .passToNative(BACKEND) / registerRaw(key, BACKEND)
velox keys in common code declared in VeloxConfig (backends-velox)

Prefix-based rules (spark.gluten.sql.columnar.backend.<backend>, spark.hadoop.fs.s3a. etc.) are kept as-is, since they are pattern rules rather than string key registrations.

How was this patch tested?

  • New/extended NativeConfRegistrySuite covering: scope registration via builder, per-scope mixed semantics, parsed-default registration for bytes confs, duplicate registration rejection, defaultToPass and transform semantics.
  • Existing config suites in gluten-core / gluten-substrait pass.
  • Compiled gluten-core, gluten-substrait, backends-velox with -Pspark-3.5,backends-velox (checkstyle/scalastyle/spotless clean). backends-clickhouse Java code compiles; the delta33 Scala compile failure on this machine is pre-existing and unrelated.

AI disclosure: this PR was developed with the assistance of Cursor (Fable 5), with human review of all changes.

…ister native confs

Currently, conf keys passed to native side are maintained in hard-coded
string lists (`nativeKeys` in GlutenConfig, `extraNative*ConfKeys` in
backend settings) that are decoupled from where the configs are defined.
This introduces an additive registration mechanism:

- `ConfigBuilder.passToNative(scope)` marks a Gluten config entry to be
  passed to native side, registered automatically on entry creation.
- `NativeConfScope` (SESSION/BACKEND/BOTH) declares whether the conf is
  passed on each native runtime creation, once at backend init, or both.
- `NativeConfRegistry` collects registrations; raw Spark/Hadoop keys can
  be registered via `registerRaw`, optionally with a default value that
  is always passed.
- `getNativeSessionConf`/`getNativeBackendConf` additionally include
  registered confs, without changing existing key lists or prefix rules.

This enables incremental migration of the hard-coded lists and allows
each module to register its own native confs on demand.

Generated-by: Claude (Cursor Agent)
@github-actions github-actions Bot added the CORE works for Gluten Core label Jul 17, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

…iveConfRegistry

Complete the migration from hard-coded native conf key lists to the declarative
passToNative mechanism:

- NativeConfRegistry now tracks session/backend scopes separately, and supports
  per-entry defaultToPass (always-send with default) and transform (value
  normalization such as byte-unit conversion and upper-casing).
- ConfigBuilder gains passToNative(scope) and passToNativeWithDefault(scope,
  default) that auto-register entries on creation, including parsed default
  values (e.g. bytes confs pass numeric bytes).
- GlutenConfig: remove the nativeKeys set, the hard-coded default value lists
  and per-key special cases in getNativeSessionConf/getNativeBackendConf; both
  methods now select confs from NativeConfRegistry plus the existing prefix
  rules. Non-Gluten keys (SQLConf/Spark core/Hadoop/S3/GCS) are registered via
  NativeConfRegistry.registerRaw in one place.
- GlutenCoreConfig/VeloxConfig: declare native passing at conf definitions;
  velox-only raw keys are registered in backends-velox instead of common code.
- Remove BackendSettingsApi.extraNativeSessionConfKeys/extraNativeBackendConfKeys
  (no overrides existed) and the now-unused GlutenConfigUtil.mapByteConfValue.
- Extend NativeConfRegistrySuite to cover scopes, defaults, transforms and
  duplicate registration.

Generated-by: Cursor 2.4.28 (Fable 5)
@github-actions github-actions Bot added the VELOX label Jul 17, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@jackylee-ch jackylee-ch changed the title [DNM][CORE] Introduce ConfigBuilder.passToNative to declaratively register native confs [DNM][CORE] Replace string-based native conf key lists with declarative NativeConfRegistry Jul 17, 2026
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.

1 participant