Skip to content

Commit

Permalink
refactor: make Ctes a struct to also store data types provided by pre…
Browse files Browse the repository at this point in the history
…pare stmt (#4520)

* refactor: make Ctes a struct to also store data types provided by prepare stmt

* chore: rename ctes to planner_context
  • Loading branch information
NGA-TRAN authored Dec 6, 2022
1 parent d9a47d6 commit bfd41a3
Show file tree
Hide file tree
Showing 2 changed files with 236 additions and 147 deletions.
9 changes: 6 additions & 3 deletions datafusion/core/tests/sqllogictests/src/insert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ use datafusion::datasource::MemTable;
use datafusion::prelude::SessionContext;
use datafusion_common::{DFSchema, DataFusionError};
use datafusion_expr::Expr as DFExpr;
use datafusion_sql::planner::SqlToRel;
use datafusion_sql::planner::{PlannerContext, SqlToRel};
use sqlparser::ast::{Expr, SetExpr, Statement as SQLStatement};
use std::collections::HashMap;
use std::sync::Arc;

pub async fn insert(ctx: &SessionContext, insert_stmt: &SQLStatement) -> Result<String> {
Expand Down Expand Up @@ -66,7 +65,11 @@ pub async fn insert(ctx: &SessionContext, insert_stmt: &SQLStatement) -> Result<
let logical_exprs = row
.into_iter()
.map(|expr| {
sql_to_rel.sql_to_rex(expr, &DFSchema::empty(), &mut HashMap::new())
sql_to_rel.sql_to_rex(
expr,
&DFSchema::empty(),
&mut PlannerContext::new(),
)
})
.collect::<std::result::Result<Vec<DFExpr>, DataFusionError>>()?;
// Directly use `select` to get `RecordBatch`
Expand Down
Loading

0 comments on commit bfd41a3

Please sign in to comment.