diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/parser/AstBuilder.java b/fe/fe-core/src/main/java/com/starrocks/sql/parser/AstBuilder.java index af009f285929f..958c9f8612452 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/parser/AstBuilder.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/parser/AstBuilder.java @@ -4919,7 +4919,7 @@ public ParseNode visitAlterPipeStatement(StarRocksParser.AlterPipeStatementConte } // ------------------------------------------- Plan Tuning Statement ----------------------------------------------- - public ParseNode visitAddPlanAdvisorStatement(StarRocksParser.AddPlanAdvisorStatementContext context) { + public ParseNode visitAlterPlanAdvisorAddStatement(StarRocksParser.AlterPlanAdvisorAddStatementContext context) { QueryStatement queryStmt = (QueryStatement) visitQueryStatement(context.queryStatement()); int start = context.queryStatement().start.getStartIndex(); int end = context.queryStatement().stop.getStopIndex(); @@ -4933,11 +4933,11 @@ public ParseNode visitAddPlanAdvisorStatement(StarRocksParser.AddPlanAdvisorStat return new AddPlanAdvisorStmt(createPos(context), queryStmt); } - public ParseNode visitClearPlanAdvisorStatement(StarRocksParser.ClearPlanAdvisorStatementContext context) { + public ParseNode visitTruncatePlanAdvisorStatement(StarRocksParser.TruncatePlanAdvisorStatementContext context) { return new ClearPlanAdvisorStmt(createPos(context)); } - public ParseNode visitDelPlanAdvisorStatement(StarRocksParser.DelPlanAdvisorStatementContext context) { + public ParseNode visitAlterPlanAdvisorDropStatement(StarRocksParser.AlterPlanAdvisorDropStatementContext context) { String advisorId = ((StringLiteral) visit(context.string())).getStringValue(); return new DelPlanAdvisorStmt(createPos(context), advisorId); } diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/parser/StarRocks.g4 b/fe/fe-core/src/main/java/com/starrocks/sql/parser/StarRocks.g4 index 69e61a559ced0..2c6199d8e06ed 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/parser/StarRocks.g4 +++ b/fe/fe-core/src/main/java/com/starrocks/sql/parser/StarRocks.g4 @@ -302,9 +302,9 @@ statement | cancelRefreshDictionaryStatement // Plan advisor statement - | addPlanAdvisorStatement - | clearPlanAdvisorStatement - | delPlanAdvisorStatement + | alterPlanAdvisorAddStatement + | truncatePlanAdvisorStatement + | alterPlanAdvisorDropStatement | showPlanAdvisorStatement // Warehouse Statement @@ -1991,14 +1991,14 @@ lock_type ; // ------------------------------------------- Plan Tuning Statement --------------------------------------------------- -addPlanAdvisorStatement - : ADD INTO PLAN ADVISOR queryStatement; +alterPlanAdvisorAddStatement + : ALTER PLAN ADVISOR ADD queryStatement; -clearPlanAdvisorStatement - : CLEAR PLAN ADVISOR; +truncatePlanAdvisorStatement + : TRUNCATE PLAN ADVISOR; -delPlanAdvisorStatement - : DELETE PLAN ADVISOR string; +alterPlanAdvisorDropStatement + : ALTER PLAN ADVISOR DROP string; showPlanAdvisorStatement : SHOW PLAN ADVISOR; diff --git a/fe/fe-core/src/test/java/com/starrocks/sql/parser/ParserTest.java b/fe/fe-core/src/test/java/com/starrocks/sql/parser/ParserTest.java index 78f6d94bc8c21..5e2b9e1d8d4ed 100644 --- a/fe/fe-core/src/test/java/com/starrocks/sql/parser/ParserTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/sql/parser/ParserTest.java @@ -59,7 +59,7 @@ class ParserTest { @Test void test() { - String sql = "add into plan advisor " + + String sql = "alter plan advisor add " + "select count(*) from customer join " + "(select * from skew_tbl where c_custkey_skew = 100) t on abs(c_custkey) = c_custkey_skew;"; SqlParser.parse(sql, new SessionVariable()); diff --git a/test/sql/test_feedback/R/test_agg_feedback b/test/sql/test_feedback/R/test_agg_feedback index 227aee23e0fe2..8c8c12bdbcd8d 100644 --- a/test/sql/test_feedback/R/test_agg_feedback +++ b/test/sql/test_feedback/R/test_agg_feedback @@ -129,7 +129,7 @@ function: assert_explain_not_contains("select count(*) from pre_agg_case group b -- result: None -- !result -add into plan advisor select count(*) from pre_agg_case group by c3; +alter plan advisor add select count(*) from pre_agg_case group by c3; -- result: [REGEX]Add query into plan advisor in FE -- !result @@ -137,7 +137,7 @@ function: assert_explain_contains("select count(*) from pre_agg_case group by c3 -- result: None -- !result -clear plan advisor; +truncate plan advisor; -- result: [REGEX]Clear all plan advisor in FE -- !result diff --git a/test/sql/test_feedback/R/test_external_table_join_feedback b/test/sql/test_feedback/R/test_external_table_join_feedback index d00bacf19fa12..68f72200563c8 100644 --- a/test/sql/test_feedback/R/test_external_table_join_feedback +++ b/test/sql/test_feedback/R/test_external_table_join_feedback @@ -44,7 +44,7 @@ function: assert_explain_not_contains("select count(*) from (select * from icebe -- result: None -- !result -add into plan advisor select count(*) from (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew t1 join (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2 where t1.c1 = 'a') t; +alter plan advisor add select count(*) from (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew t1 join (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2 where t1.c1 = 'a') t; -- result: [REGEX]Add query into plan advisor in FE* -- !result @@ -52,7 +52,7 @@ function: assert_explain_contains("select count(*) from (select * from iceberg_c -- result: None -- !result -clear plan advisor; +truncate plan advisor; -- result: [REGEX]Clear all plan advisor in FE* -- !result diff --git a/test/sql/test_feedback/R/test_join_feedback b/test/sql/test_feedback/R/test_join_feedback index 5a138c3d2b688..07782f89a060b 100644 --- a/test/sql/test_feedback/R/test_join_feedback +++ b/test/sql/test_feedback/R/test_join_feedback @@ -45,7 +45,7 @@ function: assert_explain_not_contains("select count(*) from (select * from c1_sk -- result: None -- !result -add into plan advisor select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t; +alter plan advisor add select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t; -- result: [REGEX]Add query into plan advisor in FE.* -- !result @@ -57,7 +57,7 @@ function: assert_trace_values_contains("select count(*) from (select * from c1_s -- result: None -- !result -clear plan advisor; +truncate plan advisor; -- result: [REGEX]Clear all plan advisor in FE.* -- !result diff --git a/test/sql/test_feedback/T/test_agg_feedback b/test/sql/test_feedback/T/test_agg_feedback index 6d852a5a7a3dc..0fbf93811d437 100644 --- a/test/sql/test_feedback/T/test_agg_feedback +++ b/test/sql/test_feedback/T/test_agg_feedback @@ -53,6 +53,6 @@ set enable_plan_advisor=true; set enable_plan_analyzer=true; set enable_global_runtime_filter = false; function: assert_explain_not_contains("select count(*) from pre_agg_case group by c3", "StreamingAggTuningGuide") -add into plan advisor select count(*) from pre_agg_case group by c3; +alter plan advisor add select count(*) from pre_agg_case group by c3; function: assert_explain_contains("select count(*) from pre_agg_case group by c3", "StreamingAggTuningGuide") -clear plan advisor; +truncate plan advisor; diff --git a/test/sql/test_feedback/T/test_external_table_join_feedback b/test/sql/test_feedback/T/test_external_table_join_feedback index 93f6ed6f75e5e..02e1b66b14fca 100644 --- a/test/sql/test_feedback/T/test_external_table_join_feedback +++ b/test/sql/test_feedback/T/test_external_table_join_feedback @@ -21,12 +21,12 @@ use iceberg_catalog_${uuid0}.iceberg_db_${uuid0}; set catalog default_catalog; function: assert_explain_not_contains("select count(*) from (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew t1 join (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t", "RightChildEstimationErrorTuningGuide") -add into plan advisor select count(*) from (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew t1 join (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2 where t1.c1 = 'a') t; +alter plan advisor add select count(*) from (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew t1 join (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2 where t1.c1 = 'a') t; function: assert_explain_contains("select count(*) from (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew t1 join (select * from iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2 where t1.c1 = 'a') t", "RightChildEstimationErrorTuningGuide") -clear plan advisor; +truncate plan advisor; drop table iceberg_catalog_${uuid0}.iceberg_db_${uuid0}.c1_skew; drop database iceberg_catalog_${uuid0}.iceberg_db_${uuid0}; drop catalog iceberg_catalog_${uuid0}; diff --git a/test/sql/test_feedback/T/test_join_feedback b/test/sql/test_feedback/T/test_join_feedback index 6f37d902fcb08..2873bf5777c7c 100644 --- a/test/sql/test_feedback/T/test_join_feedback +++ b/test/sql/test_feedback/T/test_join_feedback @@ -24,7 +24,7 @@ insert into c1_skew values(50001, 'f', 50001, 50001); analyze full table c1_skew with sync mode; set enable_global_runtime_filter = false; function: assert_explain_not_contains("select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t", "RightChildEstimationErrorTuningGuide") -add into plan advisor select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t; +alter plan advisor add select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t; function: assert_explain_contains("select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t", "RightChildEstimationErrorTuningGuide") function: assert_trace_values_contains("select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t", "RightChildEstimationErrorTuningGuide") -clear plan advisor; +truncate plan advisor;