Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ datafusion-common = { version = "53", default-features = false }
datafusion-functions-aggregate = { version = "53" }
datafusion-functions-window = { version = "53" }
datafusion-expr = { version = "53" }
datafusion-functions-json = { version = "0.53" }
prost = "0.14.3"
serde_json = "1"
uuid = { version = "1.23" }
Expand Down
2 changes: 2 additions & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ datafusion = { workspace = true, features = ["avro", "unicode_expressions"] }
datafusion-substrait = { workspace = true, optional = true }
datafusion-proto = { workspace = true }
datafusion-ffi = { workspace = true }
datafusion-functions-json = { workspace = true, optional = true }
prost = { workspace = true } # keep in line with `datafusion-substrait`
serde_json = { workspace = true }
uuid = { workspace = true, features = ["v4"] }
Expand All @@ -74,6 +75,7 @@ pyo3-build-config = { workspace = true }

[features]
default = ["mimalloc"]
json = ["dep:datafusion-functions-json"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: maybe we should name this community_json so that its explicit that this from community contribution, not apache repo.

thoughts?

protoc = ["datafusion-substrait/protoc"]
substrait = ["dep:datafusion-substrait"]

Expand Down
11 changes: 10 additions & 1 deletion crates/core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,16 @@ impl PySessionContext {
.with_runtime_env(runtime)
.with_default_features()
.build();
let ctx = Arc::new(SessionContext::new_with_state(session_state));
let mut ctx = SessionContext::new_with_state(session_state);

// Register JSON functions (json_extract, json_get, ->, ->>) when feature is enabled
#[cfg(feature = "json")]
datafusion_functions_json::register_all(&mut ctx)
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(
format!("Failed to register JSON functions: {e}"),
))?;

let ctx = Arc::new(ctx);
let logical_codec = Self::default_logical_codec(&ctx);
Ok(PySessionContext { ctx, logical_codec })
}
Expand Down
Loading