File tree 4 files changed +22
-4
lines changed
nautilus_core/persistence
nautilus_trader/persistence/catalog
4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,9 @@ impl DataBackendSession {
71
71
. enable_all ( )
72
72
. build ( )
73
73
. unwrap ( ) ;
74
- let session_cfg =
75
- SessionConfig :: new ( ) . set_str ( "datafusion.optimizer.repartition_file_scans" , "false" ) ;
74
+ let session_cfg = SessionConfig :: new ( )
75
+ . set_str ( "datafusion.optimizer.repartition_file_scans" , "false" )
76
+ . set_str ( "datafusion.optimizer.prefer_existing_sort" , "true" ) ;
76
77
let session_ctx = SessionContext :: new_with_config ( session_cfg) ;
77
78
Self {
78
79
session_ctx,
@@ -119,7 +120,7 @@ impl DataBackendSession {
119
120
file_sort_order : vec ! [ vec![ Expr :: Sort ( Sort {
120
121
expr: Box :: new( col( "ts_init" ) ) ,
121
122
asc: true ,
122
- nulls_first: true ,
123
+ nulls_first: false ,
123
124
} ) ] ] ,
124
125
..Default :: default ( )
125
126
} ;
@@ -129,7 +130,7 @@ impl DataBackendSession {
129
130
parquet_options,
130
131
) ) ?;
131
132
132
- let default_query = format ! ( "SELECT * FROM {}" , & table_name) ;
133
+ let default_query = format ! ( "SELECT * FROM {} ORDER BY ts_init " , & table_name) ;
133
134
let sql_query = sql_query. unwrap_or ( & default_query) ;
134
135
let query = self . runtime . block_on ( self . session_ctx . sql ( sql_query) ) ?;
135
136
Original file line number Diff line number Diff line change @@ -237,6 +237,22 @@ fn test_quote_tick_query() {
237
237
assert ! ( is_monotonically_increasing_by_init( & ticks) ) ;
238
238
}
239
239
240
+ #[ rstest]
241
+ fn test_quote_tick_query_with_filter ( ) {
242
+ let file_path = "../../tests/test_data/nautilus/quotes-3-groups-filter-query.parquet" ;
243
+ let mut catalog = DataBackendSession :: new ( 10 ) ;
244
+ catalog
245
+ . add_file :: < QuoteTick > (
246
+ "quote_005" ,
247
+ file_path,
248
+ Some ( "SELECT * FROM quote_005 WHERE ts_init >= 1701388832486000000 ORDER BY ts_init" ) ,
249
+ )
250
+ . unwrap ( ) ;
251
+ let query_result: QueryResult = catalog. get_query_result ( ) ;
252
+ let ticks: Vec < Data > = query_result. collect ( ) ;
253
+ assert ! ( is_monotonically_increasing_by_init( & ticks) ) ;
254
+ }
255
+
240
256
#[ rstest]
241
257
fn test_quote_tick_multiple_query ( ) {
242
258
let expected_length = 9_600 ;
Original file line number Diff line number Diff line change @@ -622,6 +622,7 @@ def _build_query(
622
622
if conditions :
623
623
query += f" WHERE { ' AND ' .join (conditions )} "
624
624
625
+ query += " ORDER BY ts_init"
625
626
return query
626
627
627
628
@staticmethod
You can’t perform that action at this time.
0 commit comments