Skip to content

Commit 72c7f35

Browse files
committed
Fixes after sync to 50.0.0
1 parent 78b55f0 commit 72c7f35

11 files changed

Lines changed: 45 additions & 28 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ recursive = "0.1.1"
173173
regex = "1.11"
174174
rstest = "0.25.0"
175175
serde_json = "1"
176-
sqlparser = { git = "https://github.com/Embucket/datafusion-sqlparser-rs.git", rev = "8d9cbc2669d7fc3d79d7d1d725ac20f1e9bfe10e", features = [
176+
sqlparser = { git = "https://github.com/Embucket/datafusion-sqlparser-rs.git", rev = "75ce913994c7bf8e1e9122f836da882302673bde", features = [
177177
"visitor",
178178
] }
179179
tempfile = "3"

datafusion-cli/src/functions.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,15 @@ pub struct ParquetMetadataFunc {}
322322

323323
impl TableFunctionImpl for ParquetMetadataFunc {
324324
fn call(&self, exprs: &[(Expr, Option<String>)]) -> Result<Arc<dyn TableProvider>> {
325+
if exprs.is_empty() {
326+
return plan_err!(
327+
"parquet_metadata requires string argument as its input"
328+
);
329+
}
330+
325331
let filename = match exprs.first() {
326332
Some((Expr::Literal(ScalarValue::Utf8(Some(s)), _), _)) => s, // single quote: parquet_metadata('x.parquet')
327-
Some(Expr::Column(Column { name, .. })) => name, // double quote: parquet_metadata("x.parquet")
333+
Some((Expr::Column(Column { name, .. }), _)) => name, // double quote: parquet_metadata("x.parquet")
328334
_ => {
329335
return plan_err!(
330336
"parquet_metadata requires string argument as its input"
@@ -510,7 +516,7 @@ impl MetadataCacheFunc {
510516
}
511517

512518
impl TableFunctionImpl for MetadataCacheFunc {
513-
fn call(&self, exprs: &[Expr]) -> Result<Arc<dyn TableProvider>> {
519+
fn call(&self, exprs: &[(Expr, Option<String>)]) -> Result<Arc<dyn TableProvider>> {
514520
if !exprs.is_empty() {
515521
return plan_err!("metadata_cache should have no arguments");
516522
}

datafusion/core/src/execution/session_state.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ impl Session for SessionState {
274274
}
275275

276276
impl SessionState {
277+
/// Resolve a [`TableReference`] into a [`ResolvedTableReference`] using
278+
/// the session's configured default catalog and schema.
277279
pub fn resolve_table_ref(
278280
&self,
279281
table_ref: impl Into<TableReference>,

datafusion/core/src/physical_planner.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ use datafusion_sql::TableReference;
9797
use sqlparser::ast::NullTreatment;
9898

9999
use async_trait::async_trait;
100-
use datafusion_datasource::file_groups::FileGroup;
101100
use datafusion_expr_common::operator::Operator;
102101
use datafusion_physical_plan::async_func::{AsyncFuncExec, AsyncMapper};
103102
use futures::{StreamExt, TryStreamExt};
@@ -1930,7 +1929,7 @@ pub fn transform_pivot_to_aggregate(
19301929
Box::new(Expr::Column(pivot_column.clone())),
19311930
Operator::IsNotDistinctFrom,
19321931
Box::new(Expr::Cast(Cast::new(
1933-
Box::new(Expr::Literal(value.clone())),
1932+
Box::new(Expr::Literal(value.clone(), None)),
19341933
pivot_col_type.clone(),
19351934
))),
19361935
));

datafusion/functions-table/src/generate_series.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,10 @@ impl TableFunctionImpl for GenerateSeriesFuncImpl {
521521
}
522522

523523
impl GenerateSeriesFuncImpl {
524-
fn call_int64(&self, exprs: &[Expr]) -> Result<Arc<dyn TableProvider>> {
524+
fn call_int64(&self, exprs: &[(Expr, Option<String>)]) -> Result<Arc<dyn TableProvider>> {
525525
let mut normalize_args = Vec::new();
526-
for (expr_index, expr, _) in exprs.iter().enumerate() {
527-
match expr {
526+
for (expr_index, expr) in exprs.iter().enumerate() {
527+
match &expr.0 {
528528
Expr::Literal(ScalarValue::Null, _) => {}
529529
Expr::Literal(ScalarValue::Int64(Some(n)), _) => normalize_args.push(*n),
530530
other => {
@@ -584,7 +584,7 @@ impl GenerateSeriesFuncImpl {
584584
}))
585585
}
586586

587-
fn call_timestamp(&self, exprs: &[Expr]) -> Result<Arc<dyn TableProvider>> {
587+
fn call_timestamp(&self, exprs: &[(Expr, Option<String>)]) -> Result<Arc<dyn TableProvider>> {
588588
if exprs.len() != 3 {
589589
return plan_err!(
590590
"{} function with timestamps requires exactly 3 arguments",
@@ -593,7 +593,7 @@ impl GenerateSeriesFuncImpl {
593593
}
594594

595595
// Parse start timestamp
596-
let (start_ts, tz) = match &exprs[0] {
596+
let (start_ts, tz) = match &exprs[0].0 {
597597
Expr::Literal(ScalarValue::TimestampNanosecond(ts, tz), _) => {
598598
(*ts, tz.clone())
599599
}
@@ -606,7 +606,7 @@ impl GenerateSeriesFuncImpl {
606606
};
607607

608608
// Parse end timestamp
609-
let end_ts = match &exprs[1] {
609+
let end_ts = match &exprs[1].0 {
610610
Expr::Literal(ScalarValue::Null, _) => None,
611611
Expr::Literal(ScalarValue::TimestampNanosecond(ts, _), _) => *ts,
612612
other => {
@@ -618,7 +618,7 @@ impl GenerateSeriesFuncImpl {
618618
};
619619

620620
// Parse step interval
621-
let step_interval = match &exprs[2] {
621+
let step_interval = match &exprs[2].0 {
622622
Expr::Literal(ScalarValue::Null, _) => None,
623623
Expr::Literal(ScalarValue::IntervalMonthDayNano(interval), _) => *interval,
624624
other => {
@@ -660,7 +660,7 @@ impl GenerateSeriesFuncImpl {
660660
}))
661661
}
662662

663-
fn call_date(&self, exprs: &[Expr]) -> Result<Arc<dyn TableProvider>> {
663+
fn call_date(&self, exprs: &[(Expr, Option<String>)]) -> Result<Arc<dyn TableProvider>> {
664664
if exprs.len() != 3 {
665665
return plan_err!(
666666
"{} function with dates requires exactly 3 arguments",
@@ -675,7 +675,7 @@ impl GenerateSeriesFuncImpl {
675675
)]));
676676

677677
// Parse start date
678-
let start_date = match &exprs[0] {
678+
let start_date = match &exprs[0].0 {
679679
Expr::Literal(ScalarValue::Date32(Some(date)), _) => *date,
680680
Expr::Literal(ScalarValue::Date32(None), _)
681681
| Expr::Literal(ScalarValue::Null, _) => {
@@ -693,7 +693,7 @@ impl GenerateSeriesFuncImpl {
693693
};
694694

695695
// Parse end date
696-
let end_date = match &exprs[1] {
696+
let end_date = match &exprs[1].0 {
697697
Expr::Literal(ScalarValue::Date32(Some(date)), _) => *date,
698698
Expr::Literal(ScalarValue::Date32(None), _)
699699
| Expr::Literal(ScalarValue::Null, _) => {
@@ -711,7 +711,7 @@ impl GenerateSeriesFuncImpl {
711711
};
712712

713713
// Parse step interval
714-
let step_interval = match &exprs[2] {
714+
let step_interval = match &exprs[2].0 {
715715
Expr::Literal(ScalarValue::IntervalMonthDayNano(Some(interval)), _) => {
716716
*interval
717717
}

datafusion/functions/src/regex/regexpsubstr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use regex::Regex;
3333
use std::any::Any;
3434
use std::sync::{Arc, OnceLock};
3535

36-
#[derive(Debug)]
36+
#[derive(Debug, PartialEq, Eq, Hash)]
3737
pub struct RegexpSubstrFunc {
3838
signature: Signature,
3939
}

datafusion/optimizer/src/decorrelate_predicate_subquery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl OptimizerRule for DecorrelatePredicateSubquery {
136136
Some(new_predicate),
137137
join.join_type,
138138
join.join_constraint,
139-
join.null_equals_null,
139+
join.null_equality,
140140
)?;
141141
return Ok(Transformed::yes(LogicalPlan::Join(new_join)));
142142
}

datafusion/sql/src/relation/mod.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
7777
plan_err!("Unsupported function argument type: {:?}", arg)
7878
}
7979
})
80-
.collect::<Result<Vec<_>>>()?;
80+
.collect::<Vec<_>>();
8181
let provider = self
8282
.context_provider
8383
.get_table_function_source(&tbl_func_name, args)?;
@@ -182,19 +182,29 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
182182
let func_args = args
183183
.into_iter()
184184
.map(|arg| match arg {
185-
FunctionArg::Unnamed(FunctionArgExpr::Expr(expr))
186-
| FunctionArg::Named {
185+
FunctionArg::Unnamed(FunctionArgExpr::Expr(expr)) => {
186+
// No alias
187+
self.sql_expr_to_logical_expr(expr, &schema, planner_context)
188+
.map(|e| (e, None))
189+
}
190+
FunctionArg::Named {
191+
name,
187192
arg: FunctionArgExpr::Expr(expr),
188193
..
189194
} => {
195+
// Named arg → alias comes from `name.value`
190196
self.sql_expr_to_logical_expr(expr, &schema, planner_context)
197+
.map(|e| (e, Some(name.value)))
191198
}
192199
_ => plan_err!("Unsupported function argument: {arg:?}"),
193200
})
194-
.collect::<Result<Vec<Expr>>>()?;
201+
.collect::<Result<Vec<(Expr, Option<String>)>>>()?;
202+
203+
195204
let provider = self
196205
.context_provider
197206
.get_table_function_source(tbl_func_ref.table(), func_args)?;
207+
198208
let plan =
199209
LogicalPlanBuilder::scan(tbl_func_ref.table(), provider, None)?
200210
.build()?;
@@ -250,7 +260,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
250260
)?;
251261

252262
match logical_expr {
253-
Expr::Literal(scalar) => Ok(scalar),
263+
Expr::Literal(scalar, _) => Ok(scalar),
254264
_ => plan_err!("PIVOT values must be literals"),
255265
}
256266
})
@@ -397,7 +407,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
397407
let mut projection_exprs = non_pivot_exprs.clone();
398408

399409
let name_expr =
400-
Expr::Literal(ScalarValue::Utf8(Some(col_name.to_uppercase())))
410+
Expr::Literal(ScalarValue::Utf8(Some(col_name.to_uppercase())), None)
401411
.alias(name_column.clone());
402412

403413
let value_expr =

datafusion/substrait/src/logical_plan/producer.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)