@@ -50,15 +50,17 @@ class ParsePushDownExecutorTest : public ::testing::Test
50
50
// Maybe another test has already registed, ignore exception here.
51
51
}
52
52
}
53
+ void SetUp () override
54
+ {
55
+ ctx = DB::tests::TiFlashTestEnv::getContext ();
56
+ ctx->getTimezoneInfo ().resetByTimezoneName (" Asia/Shanghai" );
57
+ default_timezone_info = DB::tests::TiFlashTestEnv::getContext ()->getTimezoneInfo ();
58
+ }
53
59
54
60
protected:
55
61
LoggerPtr log = Logger::get();
56
- ContextPtr ctx = DB::tests::TiFlashTestEnv::getContext();
57
- TimezoneInfo default_timezone_info = DB::tests::TiFlashTestEnv::getContext()->getTimezoneInfo ();
58
- DM::PushDownExecutorPtr generatePushDownExecutor (
59
- const String & table_info_json,
60
- const String & query,
61
- TimezoneInfo & timezone_info);
62
+ ContextPtr ctx;
63
+ TimezoneInfo default_timezone_info;
62
64
};
63
65
64
66
DM::PushDownExecutorPtr generatePushDownExecutor (
@@ -136,14 +138,6 @@ DM::PushDownExecutorPtr generatePushDownExecutor(
136
138
return push_down_executor;
137
139
}
138
140
139
- DM::PushDownExecutorPtr ParsePushDownExecutorTest::generatePushDownExecutor (
140
- const String & table_info_json,
141
- const String & query,
142
- TimezoneInfo & timezone_info)
143
- {
144
- return ::DB::tests::generatePushDownExecutor (*ctx, table_info_json, query, timezone_info);
145
- }
146
-
147
141
// Test cases for col and literal
148
142
TEST_F (ParsePushDownExecutorTest, ColAndLiteral)
149
143
try
160
154
{
161
155
// Equal between col and literal
162
156
auto filter = generatePushDownExecutor (
157
+ *ctx,
163
158
table_info_json,
164
159
" select * from default.t_111 where col_2 = 666" ,
165
160
default_timezone_info);
182
177
{
183
178
// Greater between col and literal
184
179
auto filter = generatePushDownExecutor (
180
+ *ctx,
185
181
table_info_json,
186
182
" select * from default.t_111 where col_2 > 666" ,
187
183
default_timezone_info);
204
200
{
205
201
// GreaterEqual between col and literal
206
202
auto filter = generatePushDownExecutor (
203
+ *ctx,
207
204
table_info_json,
208
205
" select * from default.t_111 where col_2 >= 667" ,
209
206
default_timezone_info);
226
223
{
227
224
// Less between col and literal
228
225
auto filter = generatePushDownExecutor (
226
+ *ctx,
229
227
table_info_json,
230
228
" select * from default.t_111 where col_2 < 777" ,
231
229
default_timezone_info);
248
246
{
249
247
// LessEqual between col and literal
250
248
auto filter = generatePushDownExecutor (
249
+ *ctx,
251
250
table_info_json,
252
251
" select * from default.t_111 where col_2 <= 776" ,
253
252
default_timezone_info);
284
283
{
285
284
// Equal between literal and col (take care of direction)
286
285
auto filter = generatePushDownExecutor (
286
+ *ctx,
287
287
table_info_json,
288
288
" select * from default.t_111 where 667 = col_2" ,
289
289
default_timezone_info);
306
306
{
307
307
// NotEqual between literal and col (take care of direction)
308
308
auto filter = generatePushDownExecutor (
309
+ *ctx,
309
310
table_info_json,
310
311
" select * from default.t_111 where 667 != col_2" ,
311
312
default_timezone_info);
328
329
{
329
330
// Greater between literal and col (take care of direction)
330
331
auto filter = generatePushDownExecutor (
332
+ *ctx,
331
333
table_info_json,
332
334
" select * from default.t_111 where 667 < col_2" ,
333
335
default_timezone_info);
350
352
{
351
353
// GreaterEqual between literal and col (take care of direction)
352
354
auto filter = generatePushDownExecutor (
355
+ *ctx,
353
356
table_info_json,
354
357
" select * from default.t_111 where 667 <= col_2" ,
355
358
default_timezone_info);
372
375
{
373
376
// Less between literal and col (take care of direction)
374
377
auto filter = generatePushDownExecutor (
378
+ *ctx,
375
379
table_info_json,
376
380
" select * from default.t_111 where 777 > col_2" ,
377
381
default_timezone_info);
394
398
{
395
399
// LessEqual between literal and col (take care of direction)
396
400
auto filter = generatePushDownExecutor (
401
+ *ctx,
397
402
table_info_json,
398
403
" select * from default.t_111 where 777 >= col_2" ,
399
404
default_timezone_info);
432
437
{
433
438
// Not
434
439
auto filter = generatePushDownExecutor (
440
+ *ctx,
435
441
table_info_json,
436
442
" select col_1, col_2 from default.t_111 where NOT col_2=666" ,
437
443
default_timezone_info);
459
465
{
460
466
// And
461
467
auto filter = generatePushDownExecutor (
468
+ *ctx,
462
469
table_info_json,
463
470
" select * from default.t_111 where col_1 = 'test1' and col_2 = 666" ,
464
471
default_timezone_info);
486
493
{
487
494
// OR
488
495
auto filter = generatePushDownExecutor (
496
+ *ctx,
489
497
table_info_json,
490
498
" select * from default.t_111 where col_2 = 789 or col_2 = 777" ,
491
499
default_timezone_info);
516
524
{
517
525
// And with "not supported"
518
526
auto filter = generatePushDownExecutor (
527
+ *ctx,
519
528
table_info_json,
520
529
" select * from default.t_111 where col_1 = 'test1' and not col_2 = 666" ,
521
530
default_timezone_info);
543
552
{
544
553
// And with not
545
554
auto filter = generatePushDownExecutor (
555
+ *ctx,
546
556
table_info_json,
547
557
" select * from default.t_111 where col_2 = 789 and not col_3 = 666" ,
548
558
default_timezone_info);
572
582
{
573
583
// And with or
574
584
auto filter = generatePushDownExecutor (
585
+ *ctx,
575
586
table_info_json,
576
587
" select * from default.t_111 where col_2 = 789 and (col_3 = 666 or col_3 = 678)" ,
577
588
default_timezone_info);
603
614
{
604
615
// Or with "not supported"
605
616
auto filter = generatePushDownExecutor (
617
+ *ctx,
606
618
table_info_json,
607
619
" select * from default.t_111 where col_1 = 'test1' or col_2 = 666" ,
608
620
default_timezone_info);
630
642
{
631
643
// Or with not
632
644
auto filter = generatePushDownExecutor (
645
+ *ctx,
633
646
table_info_json,
634
647
" select * from default.t_111 where col_1 = 'test1' or not col_2 = 666" ,
635
648
default_timezone_info);
657
670
{
658
671
// And between col and literal (not supported since And only support when child is ColumnExpr)
659
672
auto filter = generatePushDownExecutor (
673
+ *ctx,
660
674
table_info_json,
661
675
" select * from default.t_111 where col_2 and 1" ,
662
676
default_timezone_info);
682
696
{
683
697
// Or between col and literal (not supported since Or only support when child is ColumnExpr)
684
698
auto filter = generatePushDownExecutor (
699
+ *ctx,
685
700
table_info_json,
686
701
" select * from default.t_111 where col_2 or 1" ,
687
702
default_timezone_info);
@@ -733,14 +748,15 @@ try
733
748
// origin_time_stamp: 1802216106174185472
734
749
735
750
{
736
- // Greater between TimeStamp col and Datetime literal, use Asia/Shanghai timezone
737
751
auto ctx = TiFlashTestEnv::getContext ();
752
+ // Greater between TimeStamp col and Datetime literal, use Asia/Shanghai timezone
738
753
auto & timezone_info = ctx->getTimezoneInfo ();
739
754
timezone_info.resetByTimezoneName (" Asia/Shanghai" );
740
755
convertTimeZone (origin_time_stamp, converted_time, *timezone_info.timezone , time_zone_utc);
741
756
// converted_time: 0
742
757
743
758
auto filter = generatePushDownExecutor (
759
+ *ctx,
744
760
table_info_json,
745
761
String (" select * from default.t_111 where col_timestamp > cast_string_datetime('" ) + datetime
746
762
+ String (" ')" ),
790
806
// converted_time: 1802216518491045888
791
807
792
808
auto filter = generatePushDownExecutor (
809
+ *ctx,
793
810
table_info_json,
794
811
String (" select * from default.t_111 where col_timestamp > cast_string_datetime('" ) + datetime
795
812
+ String (" ')" ),
846
863
// converted_time: 0
847
864
848
865
auto filter = generatePushDownExecutor (
866
+ *ctx,
849
867
table_info_json,
850
868
String (" select * from default.t_111 where col_timestamp > cast_string_datetime('" ) + datetime
851
869
+ String (" ')" ),
896
914
{
897
915
// Greater between Datetime col and Datetime literal
898
916
auto filter = generatePushDownExecutor (
917
+ *ctx,
899
918
table_info_json,
900
919
String (" select * from default.t_111 where col_datetime > cast_string_datetime('" ) + datetime + String (" ')" ),
901
920
default_timezone_info);
944
963
{
945
964
// Greater between Date col and Datetime literal
946
965
auto filter = generatePushDownExecutor (
966
+ *ctx,
947
967
table_info_json,
948
968
String (" select * from default.t_111 where col_date > cast_string_datetime('" ) + datetime + String (" ')" ),
949
969
default_timezone_info);
0 commit comments