Skip to content

Commit

Permalink
feat(substrait): replace SessionContext with a trait (apache#13343)
Browse files Browse the repository at this point in the history
* feat(substrait): replace SessionContext with SessionState

* feat(substrait): add logical plan context

* chore(substrait): add apache header

* docs: fix code in docs

* docs(substrait): rename and document context

* chore(substrait): context -> state

* chore: fmt
  • Loading branch information
notfilippo authored Nov 20, 2024
1 parent a2f4878 commit 5ee524e
Show file tree
Hide file tree
Showing 15 changed files with 379 additions and 262 deletions.
4 changes: 3 additions & 1 deletion datafusion/core/src/execution/session_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ impl SessionState {
.resolve(&catalog.default_catalog, &catalog.default_schema)
}

pub(crate) fn schema_for_ref(
/// Retrieve the [`SchemaProvider`] for a specific [`TableReference`], if it
/// esists.
pub fn schema_for_ref(
&self,
table_ref: impl Into<TableReference>,
) -> datafusion_common::Result<Arc<dyn SchemaProvider>> {
Expand Down
1 change: 1 addition & 0 deletions datafusion/substrait/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ workspace = true
[dependencies]
arrow-buffer = { workspace = true }
async-recursion = "1.0"
async-trait = { workspace = true }
chrono = { workspace = true }
datafusion = { workspace = true, default-features = true }
itertools = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions datafusion/substrait/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
//! let plan = df.into_optimized_plan()?;
//!
//! // Convert the plan into a substrait (protobuf) Plan
//! let substrait_plan = logical_plan::producer::to_substrait_plan(&plan, &ctx)?;
//! let substrait_plan = logical_plan::producer::to_substrait_plan(&plan, &ctx.state())?;
//!
//! // Receive a substrait protobuf from somewhere, and turn it into a LogicalPlan
//! let logical_round_trip = logical_plan::consumer::from_substrait_plan(&ctx, &substrait_plan).await?;
//! let logical_round_trip = logical_plan::consumer::from_substrait_plan(&ctx.state(), &substrait_plan).await?;
//! let logical_round_trip = ctx.state().optimize(&logical_round_trip)?;
//! assert_eq!(format!("{:?}", plan), format!("{:?}", logical_round_trip));
//! # Ok(())
Expand Down
286 changes: 162 additions & 124 deletions datafusion/substrait/src/logical_plan/consumer.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions datafusion/substrait/src/logical_plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@

pub mod consumer;
pub mod producer;
pub mod state;
Loading

0 comments on commit 5ee524e

Please sign in to comment.