@@ -87,7 +87,7 @@ use datafusion_expr::logical_plan::builder::wrap_projection_for_join_if_necessar
8787use datafusion_expr:: utils:: { expr_to_columns, split_conjunction} ;
8888use datafusion_expr:: {
8989 Analyze , BinaryExpr , Cast , DescribeTable , DmlStatement , Explain , ExplainFormat ,
90- Extension , FetchType , Filter , JoinType , LogicalPlanBuilder , Operator , RecursiveQuery ,
90+ Extension , FetchType , Filter , JoinType , LogicalPlanBuilder , RecursiveQuery ,
9191 SkipType , StringifiedPlan , WindowFrame , WindowFrameBound , WriteOp ,
9292} ;
9393use datafusion_physical_expr:: aggregate:: { AggregateExprBuilder , AggregateFunctionExpr } ;
@@ -2212,7 +2212,8 @@ fn extract_dml_filters(
22122212 | LogicalPlan :: Repartition ( _)
22132213 | LogicalPlan :: Aggregate ( _)
22142214 | LogicalPlan :: Window ( _)
2215- | LogicalPlan :: Subquery ( _) => {
2215+ | LogicalPlan :: Subquery ( _)
2216+ | LogicalPlan :: Pivot ( _) => {
22162217 // Filter information may appear in child nodes; continue traversal
22172218 // to extract filters from Filter/TableScan nodes deeper in the plan
22182219 }
@@ -2567,26 +2568,26 @@ pub fn create_aggregate_expr_and_maybe_filter(
25672568pub fn transform_pivot_to_aggregate (
25682569 input : Arc < LogicalPlan > ,
25692570 aggregate_expr : & Expr ,
2570- pivot_column : & datafusion_common :: Column ,
2571+ pivot_column : & Column ,
25712572 pivot_values : Vec < ScalarValue > ,
25722573 default_on_null_expr : Option < & Expr > ,
25732574) -> Result < LogicalPlan > {
25742575 let df_schema = input. schema ( ) ;
25752576
2576- let all_columns: Vec < datafusion_common :: Column > = df_schema. columns ( ) ;
2577+ let all_columns: Vec < Column > = df_schema. columns ( ) ;
25772578
25782579 // Filter to include only columns we want for GROUP BY
25792580 // (exclude pivot column and aggregate expression columns)
25802581 let group_by_columns: Vec < Expr > = all_columns
25812582 . into_iter ( )
2582- . filter ( |col : & datafusion_common :: Column | {
2583+ . filter ( |col : & Column | {
25832584 col. name != pivot_column. name
25842585 && !aggregate_expr
25852586 . column_refs ( )
25862587 . iter ( )
25872588 . any ( |agg_col| agg_col. name == col. name )
25882589 } )
2589- . map ( |col : datafusion_common :: Column | Expr :: Column ( col) )
2590+ . map ( |col : Column | Expr :: Column ( col) )
25902591 . collect ( ) ;
25912592
25922593 let builder = LogicalPlanBuilder :: from ( Arc :: unwrap_or_clone ( Arc :: clone ( & input) ) ) ;
@@ -2660,7 +2661,7 @@ pub fn transform_pivot_to_aggregate(
26602661 . any ( |v| field. name ( ) == v. to_string ( ) . trim_matches ( '\'' ) )
26612662 {
26622663 projection_exprs. push ( Expr :: Column (
2663- datafusion_common :: Column :: from_name ( field. name ( ) ) ,
2664+ Column :: from_name ( field. name ( ) ) ,
26642665 ) ) ;
26652666 }
26662667 }
@@ -2669,7 +2670,7 @@ pub fn transform_pivot_to_aggregate(
26692670 for value in & pivot_values {
26702671 let field_name = value. to_string ( ) . trim_matches ( '\'' ) . to_string ( ) ;
26712672 let aggregate_col =
2672- Expr :: Column ( datafusion_common :: Column :: from_name ( & field_name) ) ;
2673+ Expr :: Column ( Column :: from_name ( & field_name) ) ;
26732674
26742675 // Create COALESCE expression using CASE: CASE WHEN col IS NULL THEN default_value ELSE col END
26752676 let coalesce_expr = Expr :: Case ( datafusion_expr:: expr:: Case {
@@ -3103,7 +3104,7 @@ impl DefaultPhysicalPlanner {
31033104 {
31043105 if !physical_exprs. iter ( ) . any ( |( _, name) | name == field. name ( ) ) {
31053106 all_exprs. push ( (
3106- Arc :: new ( Column :: new ( field. name ( ) , i) )
3107+ Arc :: new ( datafusion_physical_expr :: expressions :: Column :: new ( field. name ( ) , i) )
31073108 as Arc < dyn PhysicalExpr > ,
31083109 field. name ( ) . clone ( ) ,
31093110 ) ) ;
0 commit comments