File tree Expand file tree Collapse file tree
datafusion/expr/src/logical_plan Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2839,4 +2839,29 @@ mod tests {
28392839
28402840 Ok ( ( ) )
28412841 }
2842+
2843+ #[ test]
2844+ fn plan_builder_pivot ( ) -> Result < ( ) > {
2845+ let schema = Schema :: new ( vec ! [
2846+ Field :: new( "region" , DataType :: Utf8 , false ) ,
2847+ Field :: new( "product" , DataType :: Utf8 , false ) ,
2848+ Field :: new( "sales" , DataType :: Int32 , false ) ,
2849+ ] ) ;
2850+
2851+ let plan = LogicalPlanBuilder :: scan ( "sales" , table_source ( & schema) , None ) ?
2852+ . pivot (
2853+ col ( "sales" ) ,
2854+ Column :: from_name ( "product" ) ,
2855+ vec ! [
2856+ ScalarValue :: Utf8 ( Some ( "widget" . to_string( ) ) ) ,
2857+ ScalarValue :: Utf8 ( Some ( "gadget" . to_string( ) ) ) ,
2858+ ] ,
2859+ ) ?
2860+ . build ( ) ?;
2861+
2862+ let expected = "Pivot: sales FOR product IN (widget, gadget)\n TableScan: sales" ;
2863+ assert_eq ! ( expected, format!( "{plan}" ) ) ;
2864+
2865+ Ok ( ( ) )
2866+ }
28422867}
You can’t perform that action at this time.
0 commit comments