@@ -22,7 +22,11 @@ use crate::util::memory::MemoryHandler;
2222use crate :: { app_metrics, CubeError } ;
2323use async_trait:: async_trait;
2424use core:: fmt;
25- use datafusion:: arrow:: array:: { make_array, Array , ArrayRef , BinaryArray , BooleanArray , Decimal128Array , Float64Array , Int16Array , Int32Array , Int64Array , MutableArrayData , StringArray , TimestampMicrosecondArray , TimestampNanosecondArray , UInt16Array , UInt32Array , UInt64Array } ;
25+ use datafusion:: arrow:: array:: {
26+ make_array, Array , ArrayRef , BinaryArray , BooleanArray , Decimal128Array , Float64Array ,
27+ Int16Array , Int32Array , Int64Array , MutableArrayData , StringArray , TimestampMicrosecondArray ,
28+ TimestampNanosecondArray , UInt16Array , UInt32Array , UInt64Array ,
29+ } ;
2630use datafusion:: arrow:: compute:: SortOptions ;
2731use datafusion:: arrow:: datatypes:: { DataType , Field , Schema , SchemaRef , TimeUnit } ;
2832use datafusion:: arrow:: ipc:: reader:: StreamReader ;
@@ -43,9 +47,11 @@ use datafusion::execution::{SessionStateBuilder, TaskContext};
4347use datafusion:: logical_expr:: { Expr , LogicalPlan } ;
4448use datafusion:: physical_expr;
4549use datafusion:: physical_expr:: {
46- expressions, EquivalenceProperties , LexRequirement , PhysicalSortExpr , PhysicalSortRequirement ,
50+ expressions, Distribution , EquivalenceProperties , LexRequirement , PhysicalSortExpr ,
51+ PhysicalSortRequirement ,
4752} ;
4853use datafusion:: physical_optimizer:: optimizer:: PhysicalOptimizer ;
54+ use datafusion:: physical_optimizer:: PhysicalOptimizerRule ;
4955use datafusion:: physical_plan:: empty:: EmptyExec ;
5056use datafusion:: physical_plan:: memory:: MemoryExec ;
5157use datafusion:: physical_plan:: projection:: ProjectionExec ;
@@ -607,15 +613,13 @@ impl CubeTable {
607613 . get ( remote_path. as_str ( ) )
608614 . expect ( format ! ( "Missing remote path {}" , remote_path) . as_str ( ) ) ;
609615
610- let file_scan = FileScanConfig :: new (
611- ObjectStoreUrl :: local_filesystem ( ) ,
612- index_schema. clone ( ) ,
613- )
614- . with_file ( PartitionedFile :: from_path ( local_path. to_string ( ) ) ?)
615- . with_projection ( index_projection_or_none_on_schema_match. clone ( ) )
616- . with_output_ordering ( vec ! [ ( 0 ..key_len)
617- . map( |i| -> Result <_, DataFusionError > {
618- Ok ( PhysicalSortExpr :: new(
616+ let file_scan =
617+ FileScanConfig :: new ( ObjectStoreUrl :: local_filesystem ( ) , index_schema. clone ( ) )
618+ . with_file ( PartitionedFile :: from_path ( local_path. to_string ( ) ) ?)
619+ . with_projection ( index_projection_or_none_on_schema_match. clone ( ) )
620+ . with_output_ordering ( vec ! [ ( 0 ..key_len)
621+ . map( |i| -> Result <_, DataFusionError > {
622+ Ok ( PhysicalSortExpr :: new(
619623 Arc :: new(
620624 datafusion:: physical_expr:: expressions:: Column :: new_with_schema(
621625 index_schema. field( i) . name( ) ,
@@ -624,8 +628,8 @@ impl CubeTable {
624628 ) ,
625629 SortOptions :: default ( ) ,
626630 ) )
627- } )
628- . collect:: <Result <Vec <_>, _>>( ) ?] ) ;
631+ } )
632+ . collect:: <Result <Vec <_>, _>>( ) ?] ) ;
629633 let parquet_exec = ParquetExecBuilder :: new ( file_scan)
630634 . with_parquet_file_reader_factory ( self . parquet_metadata_cache . clone ( ) )
631635 . build ( ) ;
@@ -982,7 +986,7 @@ impl ExecutionPlan for CubeTableExec {
982986 sort_order = None
983987 }
984988 }
985- vec ! [ sort_order. map( |order| {
989+ let order = sort_order. map ( |order| {
986990 order
987991 . into_iter ( )
988992 . map ( |col_index| {
@@ -999,7 +1003,9 @@ impl ExecutionPlan for CubeTableExec {
9991003 ) )
10001004 } )
10011005 . collect ( )
1002- } ) ]
1006+ } ) ;
1007+
1008+ ( 0 ..self . children ( ) . len ( ) ) . map ( |_| order. clone ( ) ) . collect ( )
10031009 }
10041010
10051011 // TODO upgrade DF
@@ -1070,6 +1076,10 @@ impl ExecutionPlan for CubeTableExec {
10701076 fn maintains_input_order ( & self ) -> Vec < bool > {
10711077 vec ! [ true ; self . children( ) . len( ) ]
10721078 }
1079+
1080+ fn required_input_distribution ( & self ) -> Vec < Distribution > {
1081+ vec ! [ Distribution :: SinglePartition ; self . children( ) . len( ) ]
1082+ }
10731083}
10741084
10751085pub fn lex_ordering_for_index (
@@ -1540,6 +1550,10 @@ impl ExecutionPlan for ClusterSendExec {
15401550 vec ! [ false ]
15411551 }
15421552 }
1553+
1554+ fn required_input_distribution ( & self ) -> Vec < Distribution > {
1555+ vec ! [ Distribution :: SinglePartition ; self . children( ) . len( ) ]
1556+ }
15431557}
15441558
15451559impl fmt:: Debug for ClusterSendExec {
@@ -1704,14 +1718,9 @@ pub fn batches_to_dataframe(batches: Vec<RecordBatch>) -> Result<DataFrame, Cube
17041718 }
17051719 }
17061720 // TODO upgrade DF
1707- DataType :: Decimal128 ( _, _) => convert_array ! (
1708- array,
1709- num_rows,
1710- rows,
1711- Decimal128Array ,
1712- Decimal ,
1713- ( Decimal )
1714- ) ,
1721+ DataType :: Decimal128 ( _, _) => {
1722+ convert_array ! ( array, num_rows, rows, Decimal128Array , Decimal , ( Decimal ) )
1723+ }
17151724 // DataType::Int64Decimal(1) => convert_array!(
17161725 // array,
17171726 // num_rows,
0 commit comments