refactor: drive `datafusion.runtime.*` config from a `ConfigField` schema #25114
This is probably would affect user-facing with different error messages.
Concern: must sync config_namespace! schema (in runtime_options.rs) and apply_key's match arms. Miss updating second, SET fails silently with "Unknown runtime configuration" even though key parses fine.
Can be caught at compile+test time for any code path exercising new key (unit test unknown_key_is_a_plan_error pattern would catch a forgotten arm if test suite covers new field).
old {multiplier} always called with hardcoded 60 now, since Old check_overflow(config_name, mins, multiplier, secs) took multiplier as param, but only ever called once: Self::check_overflow(config_name, minutes, 60, seconds).
Behavior changes after this refactoring:
1. Error message phrasing/order: suffix style "... for 'config_name'" → new "... when setting 'config_name'".
- Affected:
- Capacity parsing (parse_capacity, was SessionContext::parse_capacity_limit)
- Duration parsing (parse_ttl, was SessionContext::parse_duration)
- Overflow (checked_secs, was check_overflow)
- max_spill_merge_fan_in (was inline in set_runtime_variable, now config_field!-generated on NonNegativeCount)
- Unknown runtime configuration: {variable} -> Unknown runtime configuration: {RUNTIME_CONFIG_PREFIX}.{key} (Text identical at runtime — variable was already "datafusion.runtime.{key}", RUNTIME_CONFIG_PREFIX is that same literal.)
2. New public API surface on datafusion-execution
- Newly exported: runtime_options::{RuntimeOptions, CapacityLimit, CacheTtl, NonNegativeCount, RUNTIME_CONFIG_PREFIX, parse_capacity, parse_capacity_limit, parse_ttl, parse_duration}.
- SessionContext::parse_capacity_limit/parse_duration (in datafusion-core) now thin wrappers over these — same signature, same return values, just relocated logic.
3. Untouched, now slightly inconsistent
- Deprecated SessionContext::parse_memory_limit (marked #[deprecated(since="53.0.0")]) keeps its own old-style inline parser, not delegating to runtime_options.
Concern: this trims down the size of DEFAULT_MAX_TEMP_DIRECTORY_SIZE from u64 to usize, which may be very different on different machines and may cause data loss.
Every member of this struct is public. I'd rather not have the implementation public and be accessed through valid APIs only and for applicable members.
The tests for this live inside datafusion-core, they should be here. We can actually get rid of this public function from here altogether once we move those tests in here.
Requested changes.
@ByteBaker Thanks for the catch!
If DEFAULT_MAX_TEMP_DIRECTORY_SIZE >= 2^32 on 32-bit target, it would cause data loss.
I like this suggestion. Only expose certain valid APIs make future internal changes easier.
I will go through all the public struct and fns to see if there are other candidates should go private.
1. I made the RuntimeOptions fields, CapacityLimit, CacheTtl, NonNegativeCount, parse_capacity and parse_ttl private. They are reached only through set_entry, reset_entry and apply_key.
2. I also added RuntimeEnvBuilder::with_config_entry and with_default_config_entry. SessionContext now uses them here, so RuntimeOptions and its methods are crate-private instead of public API.
The tests now call parse_ttl (private) directly (starting from L456), and the public parse_duration wrapper is gone.
I turned CapacityLimit into a private struct.
from_bytes / as_u64, with no conversion.From<usize> (lossless) and as_usize, which uses usize::try_from. On a target where the value doesn't fit, SET returns an error naming the key instead of truncating.
Marked as draft after 14 days without activity: failing CI checks.
Please address these items and mark Ready for review when ready.
Hi @haochunchang, are you still planning to continue this PR? If you don't have time for it anymore, I'd be happy to pick it up and build on your work here (keeping you credited). No pressure either way, just let me know.
Thanks for following up.
You can take it and feel free to pick it up. :)
On Sat, Nov 28, 2026 at 1:09 AM Arnab Mondal @.**>
wrote:
codewarnab left a comment (apache/datafusion#25114)
<https://github.com/apache/datafusion/pull/25114#issuecomment-7224079678>
> Hi @haochunchang <https://github.com/haochunchang>, are you still
planning to continue this PR? If you don't have time for it anymore, I'd be
happy to pick it up and build on your work here (keeping you credited). No
pressure either way, just let me know.
> —
Reply to this email directly, view it on GitHub
<https://github.com/apache/datafusion/pull/25114?email_source=notifications&email_token=AGASHUCZ33RAGJUOPTKGQMD53GYLVA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTOMRSGQYDOOJWG44KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-7224079678>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGASHUERIZXJBEE7HB2OZK353GYLVAVCNFSNUABFKJSXA33TNF2G64TZHMZTKOBZGE3TGMJYHNEXG43VMU5TKNBQGAYTOMBZG4ZKC5QC>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AGASHUGJR6O46FMIPOE5IN353GYLVA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTOMRSGQYDOOJWG44KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AGASHUFFFZIFVK2JCEHH27D53GYLVA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTOMRSGQYDOOJWG44KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you were mentioned.Message ID:
@.>
--
張皓鈞 HaoChun Chang
Mobile: 0918788771
Email: @.*
haochunchang
Which issue does this PR close?
Rationale for this change
The eight
datafusion.runtime.keys were duplicated across 6 places:RuntimeConfigValuesand itsinto_config_entriesRuntimeEnv::config_entriesRuntimeEnvBuilder::entriesset_runtime_variableandreset_runtime_variable.A comment asked contributors to keep the two match statements in sync by hand, and the hand-rolled parsing is what caused the panic fixed in #23316.
#23322 asks whether runtime config can use the same type-checked framework as SessionConfig/ConfigOptions instead of its own SET/RESET path.
This PR does that for parsing and dispatch:
RuntimeOptionsis built with the same config_namespace!/config_field! macros that backConfigOptions, so SET/RESET now go through ConfigFieldRuntimeOptions stays a separate struct rather than joining ConfigOptions:
This PR only unifies the framework underneath, not the two config sets themselves.
What changes are included in this PR?
1. Add
datafusion_execution::runtime_options::RuntimeOptions(crate-private) - single source of truth for the eight keys' names, descriptions, defaults, and parsing.2. Add
RuntimeEnvBuilder::with_config_entryandwith_default_config_entry, which take a fulldatafusion.runtime.key and change only that entry.-
set_runtime_variable/reset_runtime_variablenow call these and dispatch through ConfigField::set, replacing the hand-written match arms.3.
RuntimeEnvBuilder::entriesnow reads defaults from the same constants the builder itself uses (before: hardcoded strings like "100G").a. This removes a silent drift risk between actual and displayed defaults.
4.
RuntimeEnv::config_entriesis now a one-line delegate toRuntimeOptions::env_entries, which owns thedatafusion.runtimeprefix and the unlimited-pool special case.5. Three per-key listings now co-located in
runtime_options.rs:- the schema
- the from_runtime_env read of live resource objects
- the apply_key write onto RuntimeEnvBuilder
- The last two can't merge into the schema: builder setters have per-field signatures, and reported values must come from live resource objects, not from whatever was last requested.
6.
CapacityLimitstores au64behind a private field (the temp-directory limit is a disk size), so the only narrowing conversion is a checkedusize::try_from.- Values print in the largest unit that divides them exactly (1.5G shows as
1536M), and a limit that doesn't fit this platform'susizenames the key in the error.7. Error wording changed as a side effect:
-
ConfigField::setisn't given the key it's setting, so leaf parsers can't name the key mid-message like the old arms did.- Errors now get a consistent "when setting '<key>' "suffix (before: some arms said for '<key>', others when setting '<key>').
What is the testing strategy for this PR?
parse_ttloverflow, moved here from datafusion-core), defaults, SET/RESET round-trips for every key:cargo test -p datafusion-execution --lib runtime_optionscargo test -p datafusion --test core_integration runtime_configcargo test --profile=ci --test sqllogictests: Completed 512 test files in 15 seconds.cargo test --doc./dev/update_config_docs.shand diffed - generated runtime table is byte-identicalcargo fmt --all -- --checkandcargo clippy --all-targets --all-features(datafusion-execution, datafusion) cleanAre there any user-facing changes?
1. Error-message wording for invalid SET/RESET datafusion.runtime.* values — now a consistent when setting '<key>' suffix.
2. New public API:
RuntimeEnvBuilder::with_config_entryandwith_default_config_entry.3. A
CapacityLimitover 1G that isn't an exact multiple now prints in the next smaller unit (e.g.1536M).🤖 Generated with Claude Code and manually edited by @haochunchang