Skip to content

Commit

Permalink
Resolve syntax issues encountered due to bumping to ADP 32 from 28
Browse files Browse the repository at this point in the history
  • Loading branch information
jdye64 committed Oct 25, 2023
1 parent cf426ee commit 35f5927
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,16 @@ impl PyExpr {
"Bitwise operators unsupported in get_type".to_string(),
));
}
Operator::AtArrow | Operator::ArrowAt => {
todo!()
}
},
Expr::Literal(scalar_value) => match scalar_value {
ScalarValue::Boolean(_value) => "Boolean",
ScalarValue::Float32(_value) => "Float32",
ScalarValue::Float64(_value) => "Float64",
ScalarValue::Decimal128(_value, ..) => "Decimal128",
ScalarValue::Decimal256(_, _, _) => "Decimal256",
ScalarValue::Dictionary(..) => "Dictionary",
ScalarValue::Int8(_value) => "Int8",
ScalarValue::Int16(_value) => "Int16",
Expand Down
1 change: 1 addition & 0 deletions src/sql/logical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ impl PyLogicalPlan {
}
}
LogicalPlan::Unnest(_unnest) => "Unnest",
LogicalPlan::Copy(_) => "Copy",
})
}

Expand Down
13 changes: 11 additions & 2 deletions src/sql/optimizer/decorrelate_where_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use std::sync::Arc;

use datafusion_python::{
datafusion_common::{alias::AliasGenerator, context, Column, Result},
datafusion_common::{alias::AliasGenerator, context, Column, DataFusionError, Result},
datafusion_expr::{
expr::InSubquery,
expr_rewriter::unnormalize_col,
Expand Down Expand Up @@ -155,7 +155,7 @@ fn optimize_where_in(
left: &LogicalPlan,
alias: &AliasGenerator,
) -> Result<LogicalPlan> {
let projection = Projection::try_from_plan(&query_info.query.subquery)
let projection = try_from_plan(&query_info.query.subquery)
.map_err(|e| context!("a projection is required", e))?;
let subquery_input = projection.input.clone();
// TODO add the validate logic to Analyzer
Expand Down Expand Up @@ -241,6 +241,15 @@ fn remove_duplicated_filter(filters: Vec<Expr>, in_predicate: Expr) -> Vec<Expr>
.collect::<Vec<_>>()
}

fn try_from_plan(plan: &LogicalPlan) -> Result<&Projection> {
match plan {
LogicalPlan::Projection(it) => Ok(it),
_ => Err(DataFusionError::Internal(
"Could not coerce into Projection!".to_string(),
)),
}
}

struct SubqueryInfo {
query: Subquery,
where_in_expr: Expr,
Expand Down
3 changes: 1 addition & 2 deletions src/sql/optimizer/dynamic_partition_pruning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use datafusion_python::{
datafusion_expr::{
expr::InList,
logical_plan::LogicalPlan,
utils::from_plan,
Expr,
JoinType,
Operator,
Expand Down Expand Up @@ -1081,7 +1080,7 @@ fn optimize_children(
new_inputs.push(new_input.unwrap_or_else(|| input.clone()))
}
if plan_is_changed {
Ok(Some(from_plan(plan, &new_exprs, &new_inputs)?))
Ok(Some(plan.with_new_exprs(new_exprs, &new_inputs)?))
} else {
Ok(None)
}
Expand Down

0 comments on commit 35f5927

Please sign in to comment.