Skip to content

Commit

Permalink
[Refactor] adjust plan advisor syntax (StarRocks#53604)
Browse files Browse the repository at this point in the history
Signed-off-by: stephen <[email protected]>
  • Loading branch information
stephen-shelby authored Dec 5, 2024
1 parent 66c9abc commit 81424c0
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down
18 changes: 9 additions & 9 deletions fe/fe-core/src/main/java/com/starrocks/sql/parser/StarRocks.g4
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ statement
| cancelRefreshDictionaryStatement

// Plan advisor statement
| addPlanAdvisorStatement
| clearPlanAdvisorStatement
| delPlanAdvisorStatement
| alterPlanAdvisorAddStatement
| truncatePlanAdvisorStatement
| alterPlanAdvisorDropStatement
| showPlanAdvisorStatement

// Warehouse Statement
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions test/sql/test_feedback/R/test_agg_feedback
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ 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
function: assert_explain_contains("select count(*) from pre_agg_case group by c3", "StreamingAggTuningGuide")
-- result:
None
-- !result
clear plan advisor;
truncate plan advisor;
-- result:
[REGEX]Clear all plan advisor in FE
-- !result
4 changes: 2 additions & 2 deletions test/sql/test_feedback/R/test_external_table_join_feedback
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ 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
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")
-- result:
None
-- !result
clear plan advisor;
truncate plan advisor;
-- result:
[REGEX]Clear all plan advisor in FE*
-- !result
Expand Down
4 changes: 2 additions & 2 deletions test/sql/test_feedback/R/test_join_feedback
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions test/sql/test_feedback/T/test_agg_feedback
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions test/sql/test_feedback/T/test_external_table_join_feedback
Original file line number Diff line number Diff line change
Expand Up @@ -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};
4 changes: 2 additions & 2 deletions test/sql/test_feedback/T/test_join_feedback
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 81424c0

Please sign in to comment.