Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add json_get and associated methods #3

Merged
merged 13 commits into from
Apr 23, 2024
Merged

Add json_get and associated methods #3

merged 13 commits into from
Apr 23, 2024

Conversation

samuelcolvin
Copy link
Collaborator

@samuelcolvin samuelcolvin commented Apr 22, 2024

Add:

  • json_get(json: str, *keys: str | int) -> JsonUnion - Get a value from a JSON object by it's "path"
  • json_get_str(json: str, *keys: str | int) -> str - Get a string value from a JSON object by it's "path"
  • json_get_int(json: str, *keys: str | int) -> int - Get an integer value from a JSON object by it's "path"
  • json_get_float(json: str, *keys: str | int) -> float - Get a float value from a JSON object by it's "path"
  • json_get_bool(json: str, *keys: str | int) -> bool - Get a boolean value from a JSON object by it's "path"
  • json_get_json(json: str, *keys: str | int) -> str - Get any value from a JSON object by it's "path", represented as a string

@samuelcolvin samuelcolvin marked this pull request as draft April 22, 2024 18:26
"+------------------+--------------------------------------+",
];

let batches = run_query("select name, json_get(json_data, 'foo')=123 from test")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is failing with

called `Result::unwrap()` on an `Err` value: Plan("Cannot infer common argument type for comparison operation Union([(0, Field { name: \"null\", data_type: Boolean, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }), (1, Field { name: \"bool\", data_type: Boolean, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }), (2, Field { name: \"int\", data_type: Int64, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }), (3, Field { name: \"float\", data_type: Float64, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }), (4, Field { name: \"string\", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }), (5, Field { name: \"array\", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }), (6, Field { name: \"object\", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} })], Sparse) = Int64")

Unfortunately that error is occurring before before the rewriter is reached, so there's no way to rewrite the logical plan.

@samuelcolvin samuelcolvin marked this pull request as ready for review April 23, 2024 22:43
@samuelcolvin samuelcolvin changed the title Working on json_get Add json_get and associated methods Apr 23, 2024
@samuelcolvin samuelcolvin merged commit dde856b into main Apr 23, 2024
5 checks passed
@samuelcolvin samuelcolvin deleted the json_get branch April 23, 2024 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant