You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "LantaoJin (via GitHub)" <gi...@apache.org> on 2026/05/14 06:54:09 UTC

[PR] feat(builder): expose ConfigOptions.set/get as setOption / setOptions / getOption [datafusion-java]

LantaoJin opened a new pull request, #49:
URL: https://github.com/apache/datafusion-java/pull/49

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   - Closes #48 .
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   `SessionContextBuilder` (introduced in #28) currently exposes typed setters for the six most-common session knobs: `batchSize`, `targetPartitions`, `collectStatistics`, `informationSchema`, `memoryLimit`, and `tempDirectory`. The Rust `ConfigOptions` struct that backs `SessionConfig` carries roughly 200 keys split across seven sections (`datafusion.catalog.*`, `datafusion.execution.*`, `datafusion.optimizer.*`, `datafusion.sql_parser.*`, `datafusion.explain.*`, `datafusion.format.*`, plus user `extensions`). The Java builder reaches none of these except the six it names explicitly, and there is no Java surface to read any config value back at all.
   
   DataFusion already exposes string-keyed get/set on its config (`ConfigOptions::set(key, value)` and `ConfigOptions::entries()`). This PR mirrors that surface in Java rather than adding ~200 named setters and ~200 getters one at a time.
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   - One additive field on the existing `SessionOptions` proto: `map<string, string> options = 7;`. No existing field changes; wire format stays backward and forward compatible.
   - Two new methods on `SessionContextBuilder`:
     - `setOption(String key, String value)` — single entry.
     - `setOptions(Map<String, String> entries)` — bulk apply.
   - One new method on `SessionContext`:
     - `getOption(String key) → String` — read the current value of any `datafusion.*` config key. Returns the value as a string, or `null` if the key is recognised but has no value set and no default. Throws `RuntimeException` on unknown keys (mirrors `setOption`'s strictness for fast feedback on typos), and `IllegalStateException` when called on a closed context.
   - Native side:
     - `createSessionContextWithOptions` applies map entries via `config.options_mut().set(k, v)?` **after** the typed setters, so an explicit `setOption` call overrides a typed setter for the same knob.
     - New `getOptionNative` JNI handler walks `ctx.copied_config().options().entries()`.
   
   The Rust calls use the `?` form (rather than `SessionConfig::set_str(...).unwrap()`) so unknown keys or unparseable values surface as a `RuntimeException` on the Java side carrying DataFusion's error message, instead of panicking the JVM.
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   Yes, 12 new tests in `SessionContextBuilderTest`
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   
   Yes — purely additive. New public API:
   
   - `SessionContextBuilder.setOption(String, String)`
   - `SessionContextBuilder.setOptions(Map<String, String>)`
   - `SessionContext.getOption(String) → String`
   
   The new `options` field is also exposed on the existing `org.apache.datafusion.protobuf.SessionOptions` generated class (`getOptionsMap()` etc.). No API removals, no deprecations, no behavior change for callers who don't call any of the new methods.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat(builder): expose ConfigOptions.set/get as setOption / setOptions / getOption [datafusion-java]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #49:
URL: https://github.com/apache/datafusion-java/pull/49#issuecomment-4451466956

   ### Code review
   
   No issues found. Checked for bugs and CLAUDE.md compliance.
   
   Reviewed:
   - Proto evolution: new `repeated ConfigOption options = 7` is backward-compatible (no existing field changes, `repeated` correctly chosen over `map<string,string>` to preserve apply order)
   - JNI correctness: `getOptionNative` returns `null_mut()` for both the error-default and the `None`-value case, which is valid JNI for a `jstring` return type
   - Apply ordering: free-form options are applied after typed setters in `createSessionContextWithOptions` (typed knobs write to `config` first, then the `opts.options` loop writes to `config.options_mut()`, then `runtime_builder.build()`) — override semantics are correct
   - `setOption` dedup via `remove`-then-`put` correctly moves a re-issued key to the end of iteration order in `LinkedHashMap`
   - Overload resolution: `setOptions(LinkedHashMap)` vs `setOptions(Map)` — Java picks the more specific overload for a `LinkedHashMap`-typed argument, consistent with the documented intent
   - Prior PRs: no reviewer comments from PRs that touched these files apply to this change
   
   🤖 Generated with [Claude Code](https://claude.ai/code)
   
   <sub>If this code review was useful, please react with 👍. Otherwise, react with 👎.</sub>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat(builder): expose ConfigOptions.set/get as setOption / setOptions / getOption [datafusion-java]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #49:
URL: https://github.com/apache/datafusion-java/pull/49


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat(builder): expose ConfigOptions.set/get as setOption / setOptions / getOption [datafusion-java]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #49:
URL: https://github.com/apache/datafusion-java/pull/49#issuecomment-4451488701

   ### Code review
   
   No issues found. Checked for bugs and CLAUDE.md compliance.
   
   🤖 Generated with [Claude Code](https://claude.ai/code)
   
   <sub>- If this code review was useful, please react with 👍. Otherwise, react with 👎.</sub>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org