@@ -3301,14 +3301,11 @@ fn ensure_any_column_reference_is_unambiguous(
33013301
33023302#[ cfg( test) ]
33033303mod tests {
3304- use datafusion:: arrow:: array:: ArrayRef ;
3305- use datafusion:: prelude:: SessionContext ;
33063304 use std:: any:: Any ;
33073305
33083306 use sqlparser:: dialect:: { Dialect , GenericDialect , HiveDialect , MySqlDialect } ;
33093307
33103308 use datafusion_common:: assert_contains;
3311- use datafusion_expr:: { create_udaf, Accumulator , AggregateState , Volatility } ;
33123309
33133310 use super :: * ;
33143311
@@ -5330,64 +5327,6 @@ mod tests {
53305327 quick_test ( sql, expected) ;
53315328 }
53325329
5333- #[ test]
5334- fn udaf_as_window_func ( ) -> Result < ( ) > {
5335- #[ derive( Debug ) ]
5336- struct MyAccumulator ;
5337-
5338- impl Accumulator for MyAccumulator {
5339- fn state ( & self ) -> Result < Vec < AggregateState > > {
5340- unimplemented ! ( )
5341- }
5342-
5343- fn update_batch ( & mut self , _: & [ ArrayRef ] ) -> Result < ( ) > {
5344- unimplemented ! ( )
5345- }
5346-
5347- fn merge_batch ( & mut self , _: & [ ArrayRef ] ) -> Result < ( ) > {
5348- unimplemented ! ( )
5349- }
5350-
5351- fn evaluate ( & self ) -> Result < ScalarValue > {
5352- unimplemented ! ( )
5353- }
5354-
5355- fn size ( & self ) -> usize {
5356- unimplemented ! ( )
5357- }
5358- }
5359-
5360- let my_acc = create_udaf (
5361- "my_acc" ,
5362- DataType :: Int32 ,
5363- Arc :: new ( DataType :: Int32 ) ,
5364- Volatility :: Immutable ,
5365- Arc :: new ( |_| Ok ( Box :: new ( MyAccumulator ) ) ) ,
5366- Arc :: new ( vec ! [ DataType :: Int32 ] ) ,
5367- ) ;
5368-
5369- let mut context = SessionContext :: new ( ) ;
5370- context. register_table (
5371- TableReference :: Bare { table : "my_table" } ,
5372- Arc :: new ( datafusion:: datasource:: empty:: EmptyTable :: new ( Arc :: new (
5373- Schema :: new ( vec ! [
5374- Field :: new( "a" , DataType :: UInt32 , false ) ,
5375- Field :: new( "b" , DataType :: Int32 , false ) ,
5376- ] ) ,
5377- ) ) ) ,
5378- ) ?;
5379- context. register_udaf ( my_acc) ;
5380-
5381- let sql = "SELECT a, MY_ACC(b) OVER(PARTITION BY a) FROM my_table" ;
5382- let expected = r#"Projection: my_table.a, AggregateUDF { name: "my_acc", signature: Signature { type_signature: Exact([Int32]), volatility: Immutable }, fun: "<FUNC>" }(my_table.b) PARTITION BY [my_table.a] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
5383- WindowAggr: windowExpr=[[AggregateUDF { name: "my_acc", signature: Signature { type_signature: Exact([Int32]), volatility: Immutable }, fun: "<FUNC>" }(my_table.b) PARTITION BY [my_table.a] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]]
5384- TableScan: my_table"# ;
5385-
5386- let plan = context. create_logical_plan ( sql) ?;
5387- assert_eq ! ( format!( "{:?}" , plan) , expected) ;
5388- Ok ( ( ) )
5389- }
5390-
53915330 #[ test]
53925331 fn select_typed_date_string ( ) {
53935332 let sql = "SELECT date '2020-12-10' AS date" ;
0 commit comments