From 124439d160d3935b1ffe974a7e88d1f82e654636 Mon Sep 17 00:00:00 2001 From: Adam Gutglick Date: Tue, 10 Nov 2026 11:57:17 +0000 Subject: [PATCH] Bump and test the upcoming 56 release --- Cargo.toml | 9 ++++++--- src/rewrite.rs | 7 +++++-- tests/main.rs | 6 ++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cf5c6f0..dbb2334 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,10 +8,10 @@ license = "Apache-2.0" keywords = ["datafusion", "JSON", "SQL"] categories = ["database-implementations", "parsing"] repository = "https://github.com/datafusion-contrib/datafusion-functions-json/" -rust-version = "1.94.0" +rust-version = "1.95.0" [dependencies] -datafusion = { version = "55", default-features = false, features = [ +datafusion = { version = "56", default-features = false, features = [ "sql", ] } jiter = "0.17.0" @@ -21,7 +21,7 @@ serde_json = "1" [dev-dependencies] codspeed-criterion-compat = "5.0.2" -datafusion = { version = "55", default-features = false, features = [ +datafusion = { version = "56", default-features = false, features = [ "nested_expressions", "sql", ] } @@ -40,6 +40,9 @@ pedantic = { level = "deny", priority = -1 } name = "main" harness = false +[patch.crates-io] +datafusion = { git = "https://github.com/apache/datafusion.git", branch = "branch-56" } + # [patch.crates-io] # datafusion = { git = "https://github.com/apache/datafusion.git", rev = "d47bd599ee911eb4be018595b860341ff437ccb1" } # datafusion-common = { git = "https://github.com/apache/datafusion.git", rev = "d47bd599ee911eb4be018595b860341ff437ccb1" } diff --git a/src/rewrite.rs b/src/rewrite.rs index 18cc627..a9d312b 100644 --- a/src/rewrite.rs +++ b/src/rewrite.rs @@ -278,11 +278,14 @@ impl ExprPlanner for JsonExprPlanner { let alias_name = format!("{left_repr} {op} {right_repr}"); - // we put the alias in so that default column titles are `foo -> bar` instead of `json_get(foo, bar)` + // we put the alias in so that default column titles are `foo -> bar` instead of `json_get(foo, bar)`. + // An operand that is itself an operator, e.g. the `a ->> 'b'` in `a ->> 'b' ->> 0`, carries + // such an alias too; it has already gone into `alias_name`, and inside the call it would + // only clutter the plan, so it is dropped there. Ok(PlannerResult::Planned(Expr::Alias(Alias::new( Expr::ScalarFunction(ScalarFunction { func: op.into(), - args: vec![expr.left, expr.right], + args: vec![expr.left.unalias(), expr.right.unalias()], }), None::<&str>, alias_name, diff --git a/tests/main.rs b/tests/main.rs index edd2175..07ff9d1 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -1793,9 +1793,11 @@ async fn test_double_arrow_double_nested_cast() { async fn test_plan_double_arrow_double_nested_cast() { let lines = logical_plan(r"explain select (json_data->>'foo'->>0)::int from test").await; - // NB: json_as_text(..)::int is NOT the same as `json_get_int(..)`, hence the cast is not rewritten + // NB: json_as_text(..)::int is NOT the same as `json_get_int(..)`, hence the cast is not rewritten. + // The cast is planned around the aliased `->>`, so the alias, and with it the column name, is + // inside the cast. let expected = [ - "Projection: CAST(json_as_text(json_as_text(test.json_data, Utf8(\"foo\")), Int64(0)) AS Int32) AS json_data ->> 'foo' ->> 0", + "Projection: CAST(json_as_text(json_as_text(test.json_data, Utf8(\"foo\")), Int64(0)) AS json_data ->> 'foo' ->> 0 AS Int32)", " TableScan: test projection=[json_data]", ];