@@ -53,7 +53,7 @@ use crate::catalog::Snapshot as CatalogSnapshot;
53
53
use crate :: event;
54
54
use crate :: handlers:: http:: query:: QueryError ;
55
55
use crate :: option:: Mode ;
56
- use crate :: parseable:: { Stream , PARSEABLE } ;
56
+ use crate :: parseable:: PARSEABLE ;
57
57
use crate :: storage:: { ObjectStorageProvider , ObjectStoreFormat , STREAM_ROOT_DIRECTORY } ;
58
58
use crate :: utils:: time:: TimeRange ;
59
59
@@ -131,12 +131,10 @@ impl Query {
131
131
132
132
pub async fn execute (
133
133
& self ,
134
- stream : & Stream ,
134
+ time_partition : Option < & String > ,
135
135
) -> Result < ( Vec < RecordBatch > , Vec < String > ) , ExecuteError > {
136
- let time_partition = stream. get_time_partition ( ) ;
137
-
138
136
let df = QUERY_SESSION
139
- . execute_logical_plan ( self . final_logical_plan ( & time_partition) )
137
+ . execute_logical_plan ( self . final_logical_plan ( time_partition) )
140
138
. await ?;
141
139
142
140
let fields = df
@@ -155,18 +153,19 @@ impl Query {
155
153
Ok ( ( results, fields) )
156
154
}
157
155
158
- pub async fn get_dataframe ( & self , stream_name : String ) -> Result < DataFrame , ExecuteError > {
159
- let time_partition = PARSEABLE . get_stream ( & stream_name) ?. get_time_partition ( ) ;
160
-
156
+ pub async fn get_dataframe (
157
+ & self ,
158
+ time_partition : Option < & String > ,
159
+ ) -> Result < DataFrame , ExecuteError > {
161
160
let df = QUERY_SESSION
162
- . execute_logical_plan ( self . final_logical_plan ( & time_partition) )
161
+ . execute_logical_plan ( self . final_logical_plan ( time_partition) )
163
162
. await ?;
164
163
165
164
Ok ( df)
166
165
}
167
166
168
167
/// return logical plan with all time filters applied through
169
- fn final_logical_plan ( & self , time_partition : & Option < String > ) -> LogicalPlan {
168
+ fn final_logical_plan ( & self , time_partition : Option < & String > ) -> LogicalPlan {
170
169
// see https://github.com/apache/arrow-datafusion/pull/8400
171
170
// this can be eliminated in later version of datafusion but with slight caveat
172
171
// transform cannot modify stringified plans by itself
@@ -486,7 +485,7 @@ fn transform(
486
485
plan : LogicalPlan ,
487
486
start_time : NaiveDateTime ,
488
487
end_time : NaiveDateTime ,
489
- time_partition : & Option < String > ,
488
+ time_partition : Option < & String > ,
490
489
) -> Transformed < LogicalPlan > {
491
490
plan. transform ( & |plan| match plan {
492
491
LogicalPlan :: TableScan ( table) => {
@@ -544,7 +543,7 @@ fn transform(
544
543
545
544
fn table_contains_any_time_filters (
546
545
table : & datafusion:: logical_expr:: TableScan ,
547
- time_partition : & Option < String > ,
546
+ time_partition : Option < & String > ,
548
547
) -> bool {
549
548
table
550
549
. filters
@@ -558,8 +557,8 @@ fn table_contains_any_time_filters(
558
557
} )
559
558
. any ( |expr| {
560
559
matches ! ( & * expr. left, Expr :: Column ( Column { name, .. } )
561
- if ( ( time_partition. is_some ( ) && name == time_partition . as_ref ( ) . unwrap ( ) ) ||
562
- ( ! time_partition. is_some ( ) && name == event:: DEFAULT_TIMESTAMP_KEY ) ) )
560
+ if ( time_partition. is_some_and ( |field| field == name ) ||
561
+ ( time_partition. is_none ( ) && name == event:: DEFAULT_TIMESTAMP_KEY ) ) )
563
562
} )
564
563
}
565
564
0 commit comments