Title: feat: expose ConfigOptions.set/get as generic SessionContextBuilder.setOption / SessionContext.getOption · Issue #48 · apache/datafusion-java · GitHub
Open Graph Title: feat: expose ConfigOptions.set/get as generic SessionContextBuilder.setOption / SessionContext.getOption · Issue #48 · apache/datafusion-java
X Title: feat: expose ConfigOptions.set/get as generic SessionContextBuilder.setOption / SessionContext.getOption · Issue #48 · apache/datafusion-java
Description: Is your feature request related to a problem or challenge? SessionContextBuilder (introduced in #28) exposes a typed setter for the six most-common SessionConfig knobs: batchSize, targetPartitions, collectStatistics, informationSchema, m...
Open Graph Description: Is your feature request related to a problem or challenge? SessionContextBuilder (introduced in #28) exposes a typed setter for the six most-common SessionConfig knobs: batchSize, targetPartitions,...
X Description: Is your feature request related to a problem or challenge? SessionContextBuilder (introduced in #28) exposes a typed setter for the six most-common SessionConfig knobs: batchSize, targetPartitions,...
Opengraph URL: https://github.com/apache/datafusion-java/issues/48
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat: expose ConfigOptions.set/get as generic SessionContextBuilder.setOption / SessionContext.getOption","articleBody":"### Is your feature request related to a problem or challenge?\n\n`SessionContextBuilder` (introduced in #28) exposes a typed setter for the six most-common `SessionConfig` knobs: `batchSize`, `targetPartitions`, `collectStatistics`, `informationSchema`, `memoryLimit`, and `tempDirectory`. There is currently no Java surface to **read** any config value back, either.\n\nThe 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.\n\nA few representative gaps the *typed* approach would have to fill one at a time, but a *generic* `setOption(key, value)` lights up in a single PR:\n\n- `datafusion.execution.parquet.pushdown_filters` — decode-time predicate pushdown via `RowFilter`. Workload-dependent default; many embedders flip this per-context.\n- `datafusion.execution.parquet.bloom_filter_on_read`, `…parquet.reorder_filters`, `…parquet.schema_force_view_types`, `…parquet.binary_as_string` — the rest of the parquet family.\n- `datafusion.optimizer.prefer_hash_join`, `…optimizer.default_filter_selectivity`, `…optimizer.repartition_joins`, `…optimizer.expand_views_at_output` — optimizer dials almost every embedder ends up tuning.\n- `datafusion.execution.time_zone` — required for any timestamp arithmetic that needs a non-UTC zone.\n- `datafusion.format.timestamp_format`, `…format.date_format`, `…format.binary_format` — affect every `DataFrame.show()` and any text rendering.\n- `datafusion.sql_parser.dialect`, `…sql_parser.enable_ident_normalization` — needed to integrate with non-PostgreSQL frontends (MySQL, Snowflake, Hive, …).\n- `datafusion.explain.show_statistics`, `…explain.show_sizes`, `…explain.format` — needed by tooling/UI built on top of `EXPLAIN`.\n- User `extensions` set via `Extensions::insert(...)` — currently unreachable from Java at any granularity.\n\nDataFusion already exposes string-keyed get/set on its config (`ConfigOptions::set(key, value)` and `ConfigOptions::entries()`). The Java binding can mirror both directly:\n\n```rust\nconfig.options_mut().set(key, value)?; // ConfigOptions::set\nctx.copied_config().options().entries(); // ConfigOptions::entries\n```\n\nThis issue tracks adding the matching Java surface for both directions.\n\n### Describe the solution you'd like\n\nThree new methods, two on `SessionContextBuilder` and one on `SessionContext`:\n\n```java\nctx.builder()\n .batchSize(8192) // existing typed\n .targetPartitions(16) // existing typed\n .setOption(\"datafusion.execution.parquet.pushdown_filters\", \"true\")\n .setOption(\"datafusion.optimizer.prefer_hash_join\", \"true\")\n .setOptions(Map.of( // bulk overload\n \"datafusion.execution.time_zone\", \"UTC\",\n \"datafusion.optimizer.default_filter_selectivity\", \"10\"))\n .build();\n\n// read side, on the constructed context:\nString tz = ctx.getOption(\"datafusion.execution.time_zone\");\n```\n\n### Wire format\n\nPurely additive — one new field on the existing `SessionOptions` proto:\n\n```protobuf\nmessage SessionOptions {\n optional uint64 batch_size = 1;\n // ... unchanged ...\n optional string temp_directory = 6;\n map\u003cstring, string> options = 7; // new\n}\n```\n\n`map\u003cstring, string>` over `repeated KeyValue` because:\n- The Java/Rust generated APIs are nicer (`putOptions` / `HashMap\u003cString,String>` rather than a wrapper struct).\n- Each key is unique by definition, which is the constraint we want.\n- Wire bytes are identical to a repeated KV under proto3.\n\n### setOption / setOptions (write side)\n\n```java\npublic SessionContextBuilder setOption(String key, String value) {\n if (key == null || value == null) {\n throw new IllegalArgumentException(\"setOption key and value must be non-null\");\n }\n this.options.put(key, value); // LinkedHashMap\u003cString, String>\n return this;\n}\n\npublic SessionContextBuilder setOptions(Map\u003cString, String> entries) { ... }\n```\n\nStored into a `LinkedHashMap\u003cString, String>` so caller-order is preserved on the Java side; serialized via `b.putAllOptions(...)` into the proto.\n\n### getOption (read side)\n\n```java\npublic String getOption(String key) { ... }\n```\n\nLives on `SessionContext` rather than the builder, because the value it returns is \"what DataFusion actually compiled\" — only knowable post-construction. Returns the value as a `String`, or `null` if the key is recognised but has no value set and no default. Unknown keys throw `RuntimeException` to mirror `setOption`'s strictness, and a closed-context call throws `IllegalStateException` like every other method on the class.\n\nReturning a plain `String` rather than a richer `ConfigEntry { key, value, description }` because the Java side has no `ConfigEntry` mirror today; introducing one is review surface for another day, and a richer return type is purely additive.\n\n### Rust surface\n\nIn `native/src/lib.rs::createSessionContextWithOptions`, after the existing typed-field decoding:\n\n```rust\nlet mut config = SessionConfig::new();\n// ... existing typed setters unchanged ...\nfor (k, v) in &opts.options {\n config.options_mut().set(k, v)?;\n}\n```\n\nPlus a new `getOptionNative` JNI handler that walks `ctx.copied_config().options().entries()` and returns the matching `entry.value` as a `JString`, or `null` for known-but-unset.\n\n`ConfigOptions::set` returns a `DataFusionError` on unknown keys or unparseable values, which `try_unwrap_or_throw` already surfaces as a `RuntimeException` with the underlying message — same error path as the rest of the JNI crate.\n\n### Behavior precedence\n\nMap entries are applied **after** the typed setters, so a caller that sets both `batchSize(8192)` and `setOption(\"datafusion.execution.batch_size\", \"1\")` gets the overriding behavior. This is the only semantically defensible order (otherwise the typed-setter-wins case would silently drop the explicit `setOption` call), but flagged here for explicit reviewer sign-off — see *Open questions* below.\n\n### Out of scope (separate follow-ups)\n\n- Read-time options like `CsvReadOptions.has_header` — per-call, already typed, not session-level.\n- Compile-time validation of keys. Java has no way to know whether a key string is valid in the pinned DataFusion version; we rely on the runtime error from `ConfigOptions::set`. Same UX as the Rust string-keyed API.\n- A typed `ConfigException` hierarchy. Today every JNI error collapses to `RuntimeException`. Promoting these to typed exceptions is a separate cross-cutting concern.\n- A `listOptions()` enumerator returning all keys. Useful for tooling but not needed by users; easy follow-up if requested.\n\n\n### Out of scope (separate follow-ups)\n\n- Read-time options like `CsvReadOptions.has_header` per-call, already typed, not session-level.\n- Compile-time validation of keys. Java has no way to know whether a key string is valid in the pinned DataFusion version; we rely on the runtime error from `ConfigOptions::set`. Same UX as the Rust string-keyed API.\n- A typed `ConfigException` hierarchy. Today every JNI error collapses to `RuntimeException`. Promoting these to typed exceptions is a separate cross-cutting concern (see related work in `prs/CONTRIB_ISSUES.md` #12 in the OpenSearch-sourced backlog).\n\n### Describe alternatives you've considered\n\n1. **One named setter per key**, e.g. `parquetPushdownFilters(boolean)`. Originally drafted as the first cut. Rejected because it scales to ~200 setters and forces a separate PR for every new dial DataFusion adds upstream. Named setters for the *common* knobs (the six already in #28) are the right call; a generic escape hatch covers the long tail.\n\n2. **A bundled `parquetOptions(ParquetSessionOptions)` builder per-section.** Decent ergonomics but loses everything outside parquet, and forces us to re-design the surface every time DataFusion adds a section. The `setOption(key, value)` shape tracks the upstream API exactly and needs no follow-up when new keys are added.\n\n3. **getOption on the builder instead of on `SessionContext`.** Considered but rejected: a builder-side getter would only know what's pending in the local map, which is strictly worse than reading what DataFusion actually compiled. The post-construction `SessionContext.getOption` is the meaningful contract.\n\n4. **Returning `null` for unknown keys instead of throwing.** Conflates \"no such key\" (caller typo) with \"known-but-unset\" (legitimate state). Throwing on unknown keys matches `setOption`'s strictness and gives faster feedback on typos.\n\n### Additional context\n\n_No response_","author":{"url":"https://github.com/LantaoJin","@type":"Person","name":"LantaoJin"},"datePublished":"2026-05-14T06:07:24Z","url":"https://github.com/apache/datafusion-java/issues/48"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:33a76208-8be7-ebfc-504e-5f13913bf881 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FD2:208411:2E1FDC:3F5A77:6B046A0B |
| html-safe-nonce | 764de4e4304f5573b856ea5fec3f02625514379cbc6760b5ae1aa5631e029785 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkQyOjIwODQxMToyRTFGREM6M0Y1QTc3OjZCMDQ2QTBCIiwidmlzaXRvcl9pZCI6IjQwOTI4MDExODU3MTc5NzE0NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 30463e7d65f3750d704e4f3d4d203962cb63c689f6cb62716a308e0a5640cb56 |
| hovercard-subject-tag | issue:4443643995 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/apache/datafusion-java/48/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0aacdd0b048fe5d1b033192c86bb1f37b2c128b2e60962cee680da96e348d626/apache/datafusion-java/issues/48 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0aacdd0b048fe5d1b033192c86bb1f37b2c128b2e60962cee680da96e348d626/apache/datafusion-java/issues/48 |
| og:image:alt | Is your feature request related to a problem or challenge? SessionContextBuilder (introduced in #28) exposes a typed setter for the six most-common SessionConfig knobs: batchSize, targetPartitions,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LantaoJin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| turbo-cache-control | no-preview |
| go-import | github.com/apache/datafusion-java git https://github.com/apache/datafusion-java.git |
| octolytics-dimension-user_id | 47359 |
| octolytics-dimension-user_login | apache |
| octolytics-dimension-repository_id | 1237105117 |
| octolytics-dimension-repository_nwo | apache/datafusion-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1237105117 |
| octolytics-dimension-repository_network_root_nwo | apache/datafusion-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width