@@ -234,6 +234,19 @@ protected void runBeforeAll() throws Exception {
234
234
+ " \" replication_num\" = \" 1\" \n "
235
235
+ ");\n "
236
236
);
237
+ createTable ("CREATE TABLE `test3` (\n "
238
+ + " `id` VARCHAR(36) NOT NULL COMMENT 'id',\n "
239
+ + " `created_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ''\n "
240
+ + ") ENGINE=OLAP\n "
241
+ + "DUPLICATE KEY(`id`)\n "
242
+ + "COMMENT ''\n "
243
+ + "PARTITION BY RANGE(`created_time`)\n "
244
+ + "(PARTITION P_2024071713 VALUES [('2024-07-17 13:00:00'), ('2024-07-17 14:00:00')),\n "
245
+ + "PARTITION P_2024071714 VALUES [('2024-07-17 14:00:00'), ('2024-07-17 15:00:00')))\n "
246
+ + "DISTRIBUTED BY HASH(`id`) BUCKETS AUTO\n "
247
+ + "PROPERTIES (\n "
248
+ + "\" replication_allocation\" = \" tag.location.default: 1\" \n "
249
+ + ");\n " );
237
250
// Should not make scan to empty relation when the table used by materialized view has no data
238
251
connectContext .getSessionVariable ().setDisableNereidsRules ("OLAP_SCAN_PARTITION_PRUNE,PRUNE_EMPTY_PARTITION" );
239
252
}
@@ -809,6 +822,42 @@ public void containTableQueryOperatorWithoutOperatorTest() {
809
822
});
810
823
}
811
824
825
+ @ Test
826
+ public void getRelatedTableInfoWhenMultiPartitionExprs () {
827
+ PlanChecker .from (connectContext )
828
+ .checkExplain ("select id, date_trunc(created_time, 'minute') as created_time_minute,"
829
+ + " min(created_time) as start_time,"
830
+ + " if(count(id) > 0, 1, 0) as status\n "
831
+ + " from test3 \n "
832
+ + " group by id, date_trunc(created_time, 'minute')" ,
833
+ nereidsPlanner -> {
834
+ Plan rewrittenPlan = nereidsPlanner .getRewrittenPlan ();
835
+ RelatedTableInfo relatedTableInfo =
836
+ MaterializedViewUtils .getRelatedTableInfo ("created_time_minute" ,
837
+ "day" , rewrittenPlan , nereidsPlanner .getCascadesContext ());
838
+ checkRelatedTableInfo (relatedTableInfo ,
839
+ "test3" ,
840
+ "created_time" ,
841
+ true );
842
+ });
843
+ PlanChecker .from (connectContext )
844
+ .checkExplain ("select id, date_trunc(created_time, 'hour') as created_time_hour,"
845
+ + " min(created_time) as start_time\n "
846
+ + " from test3 \n "
847
+ + " group by id, date_trunc(created_time, 'minute'),"
848
+ + " date_trunc(created_time, 'hour');" ,
849
+ nereidsPlanner -> {
850
+ Plan rewrittenPlan = nereidsPlanner .getRewrittenPlan ();
851
+ RelatedTableInfo relatedTableInfo =
852
+ MaterializedViewUtils .getRelatedTableInfo ("created_time_hour" ,
853
+ "day" , rewrittenPlan , nereidsPlanner .getCascadesContext ());
854
+ checkRelatedTableInfo (relatedTableInfo ,
855
+ "test3" ,
856
+ "created_time" ,
857
+ true );
858
+ });
859
+ }
860
+
812
861
private void checkRelatedTableInfo (RelatedTableInfo relatedTableInfo ,
813
862
String expectTableName ,
814
863
String expectColumnName ,
0 commit comments