feat: add optional JSON functions crate with json_get_str scaffolding#21353
Open
crm26 wants to merge 1 commit intoapache:mainfrom
Open
feat: add optional JSON functions crate with json_get_str scaffolding#21353crm26 wants to merge 1 commit intoapache:mainfrom
crm26 wants to merge 1 commit intoapache:mainfrom
Conversation
Adds a new `datafusion-functions-json` crate to the workspace with `json_get_str` as the initial function, establishing the integration pattern for bringing JSON functions into core DataFusion. This PR implements the scaffolding discussed in apache#21301: - New crate `datafusion/functions-json/` with registration hook - `json_get_str(json, *keys) -> str` extracts a string value from a JSON string at the given path (supports nested keys and array indices) - Optional feature flag `json_expressions` on the core crate (not default) - Handles Utf8, LargeUtf8, and Utf8View string types - Minimum 2 args enforced at planning time via coerce_types - SQL-level tests via sqllogictest - 9 unit tests + 1 doctest Follow-on PRs will add the remaining functions from datafusion-functions-json (json_get, json_get_int, json_get_float, json_get_bool, json_get_json, json_get_array, json_as_text, json_length, json_contains, and -> / ->> operators). Closes apache#21301 (partial)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
datafusion-functions-jsoncrate to the workspace withjson_get_stras the initial function, establishing the integration pattern for bringing JSON functions into core DataFusion.Per @alamb's suggestion in #21301:
What's included
datafusion/functions-json/withregister_all()hookjson_get_str(json, *keys) -> str— extracts a string value from a JSON string at the given path (supports nested keys and array indices)json_expressionson the core crate (not enabled by default)Utf8,LargeUtf8, andUtf8Viewstring typescoerce_typesjson_functions.slt)Design notes
serde_json(already a workspace dependency) for JSON parsing. The existingdatafusion-contrib/datafusion-functions-jsoncrate usesjiterfor better performance — follow-on PRs can switch the implementation while keeping the same interface.json_expressions, matching the pattern ofnested_expressions,unicode_expressions, etc.session_state_defaults.rs, same as other function crates.Follow-on PRs
Will add the remaining functions from
datafusion-functions-json:json_get,json_get_int,json_get_float,json_get_bool,json_get_json,json_get_array,json_as_text,json_length,json_contains, and->/->>operators.Ref: #21301