[Refactor](admin-stmt) rename some admin-show statestmt (#29492)

The `ADMIN SHOW` statement can not be executed with high version of mysql 8.x jdbc driver.
So I rename these statement, remove the `ADMIN` keywords.

1. ADMIN SHOW CONFIG -> SHOW CONFIG
2. ADMIN SHOW REPLICA -> SHOW REPLICA
3. ADMIN DIAGNOSE TABLET -> SHOW TABLET DIAGNOSIS
4. ADMIN SHOW TABLET -> SHOW TABLET

for compatibility, the old statements are still supported, but not recommend to use.
They will be removed in later version
This commit is contained in:
Mingyu Chen
2024-01-10 18:04:18 +08:00
committed by yiguolei
parent 5d0732fcf4
commit 697a6a4ba2
50 changed files with 231 additions and 186 deletions

View File

@ -345,6 +345,7 @@ terminal String
KW_DESC,
KW_DESCRIBE,
KW_DIAGNOSE,
KW_DIAGNOSIS,
KW_DISK,
KW_DISTINCT,
KW_DISTINCTPC,
@ -4340,6 +4341,30 @@ show_param ::=
{:
RESULT = new ShowConvertLSCStmt(db);
:}
| KW_REPLICA KW_STATUS KW_FROM base_table_ref:table_ref opt_wild_where
{:
RESULT = new ShowReplicaStatusStmt(table_ref, parser.where);
:}
| KW_REPLICA KW_DISTRIBUTION KW_FROM base_table_ref:table_ref
{:
RESULT = new ShowReplicaDistributionStmt(table_ref);
:}
| KW_FRONTEND KW_CONFIG opt_wild_where
{:
RESULT = new ShowConfigStmt(AdminSetConfigStmt.ConfigType.FRONTEND, parser.wild);
:}
| KW_TABLET KW_STORAGE KW_FORMAT
{:
RESULT = new ShowTabletStorageFormatStmt(false);
:}
| KW_TABLET KW_STORAGE KW_FORMAT KW_VERBOSE
{:
RESULT = new ShowTabletStorageFormatStmt(true);
:}
| KW_TABLET KW_DIAGNOSIS INTEGER_LITERAL:tabletId
{:
RESULT = new DiagnoseTabletStmt(tabletId);
:}
;
opt_tmp ::=
@ -7364,13 +7389,15 @@ integer_list ::=
;
admin_stmt ::=
// deprecated
KW_ADMIN KW_SHOW KW_REPLICA KW_STATUS KW_FROM base_table_ref:table_ref opt_wild_where
{:
RESULT = new AdminShowReplicaStatusStmt(table_ref, parser.where);
RESULT = new ShowReplicaStatusStmt(table_ref, parser.where);
:}
// deprecated
| KW_ADMIN KW_SHOW KW_REPLICA KW_DISTRIBUTION KW_FROM base_table_ref:table_ref
{:
RESULT = new AdminShowReplicaDistributionStmt(table_ref);
RESULT = new ShowReplicaDistributionStmt(table_ref);
:}
| KW_ADMIN KW_SET KW_REPLICA KW_STATUS KW_PROPERTIES LPAREN key_value_map:prop RPAREN
{:
@ -7396,9 +7423,10 @@ admin_stmt ::=
{:
RESULT = new AdminSetConfigStmt(AdminSetConfigStmt.ConfigType.FRONTEND, configs);
:}
// deprecated
| KW_ADMIN KW_SHOW KW_FRONTEND KW_CONFIG opt_wild_where
{:
RESULT = new AdminShowConfigStmt(AdminSetConfigStmt.ConfigType.FRONTEND, parser.wild);
RESULT = new ShowConfigStmt(AdminSetConfigStmt.ConfigType.FRONTEND, parser.wild);
:}
| KW_ADMIN KW_CHECK KW_TABLET LPAREN integer_list:tabletIds RPAREN opt_properties:properties
{:
@ -7432,17 +7460,20 @@ admin_stmt ::=
{:
RESULT = new AdminSetPartitionVersionStmt(name, properties);
:}
// deprecated
| KW_ADMIN KW_DIAGNOSE KW_TABLET INTEGER_LITERAL:tabletId
{:
RESULT = new AdminDiagnoseTabletStmt(tabletId);
RESULT = new DiagnoseTabletStmt(tabletId);
:}
// deprecated
| KW_ADMIN KW_SHOW KW_TABLET KW_STORAGE KW_FORMAT
{:
RESULT = new AdminShowTabletStorageFormatStmt(false);
RESULT = new ShowTabletStorageFormatStmt(false);
:}
// deprecated
| KW_ADMIN KW_SHOW KW_TABLET KW_STORAGE KW_FORMAT KW_VERBOSE
{:
RESULT = new AdminShowTabletStorageFormatStmt(true);
RESULT = new ShowTabletStorageFormatStmt(true);
:}
| KW_ADMIN KW_COPY KW_TABLET INTEGER_LITERAL:tabletId opt_properties:properties
{:
@ -7667,6 +7698,8 @@ keyword ::=
{: RESULT = id; :}
| KW_DIAGNOSE:id
{: RESULT = id; :}
| KW_DIAGNOSIS:id
{: RESULT = id; :}
| KW_DISTINCTPC:id
{: RESULT = id; :}
| KW_DISTINCTPCSA:id

View File

@ -29,15 +29,15 @@ import org.apache.doris.qe.ShowResultSetMetaData;
import com.google.common.collect.ImmutableList;
// ADMIN DIAGNOSE TABLET tablet_id
public class AdminDiagnoseTabletStmt extends ShowStmt {
// SHOW TABLET DIAGNOSIS tablet_id
public class DiagnoseTabletStmt extends ShowStmt {
public static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>()
.add("Item").add("Info").add("Suggestion")
.build();
private long tabletId;
public AdminDiagnoseTabletStmt(long tabletId) {
public DiagnoseTabletStmt(long tabletId) {
this.tabletId = tabletId;
}
@ -57,7 +57,7 @@ public class AdminDiagnoseTabletStmt extends ShowStmt {
@Override
public String toSql() {
return "ADMIN DIAGNOSE TABLET " + tabletId;
return "SHOW TABLET DIAGNOSIS " + tabletId;
}
@Override

View File

@ -31,8 +31,8 @@ import org.apache.doris.qe.ShowResultSetMetaData;
import com.google.common.collect.ImmutableList;
// admin show frontend config;
public class AdminShowConfigStmt extends ShowStmt {
// show frontend config;
public class ShowConfigStmt extends ShowStmt {
public static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>().add("Key").add(
"Value").add("Type").add("IsMutable").add("MasterOnly").add("Comment").build();
@ -40,7 +40,7 @@ public class AdminShowConfigStmt extends ShowStmt {
private String pattern;
public AdminShowConfigStmt(ConfigType type, String pattern) {
public ShowConfigStmt(ConfigType type, String pattern) {
this.type = type;
this.pattern = pattern;
}

View File

@ -31,8 +31,8 @@ import org.apache.doris.qe.ShowResultSetMetaData;
import com.google.common.collect.ImmutableList;
// admin show replica distribution from tbl [partition(p1, p2, ...)]
public class AdminShowReplicaDistributionStmt extends ShowStmt {
// show replica distribution from tbl [partition(p1, p2, ...)]
public class ShowReplicaDistributionStmt extends ShowStmt {
public static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>()
.add("BackendId").add("ReplicaNum").add("ReplicaSize")
.add("NumGraph").add("NumPercent")
@ -41,7 +41,7 @@ public class AdminShowReplicaDistributionStmt extends ShowStmt {
private TableRef tblRef;
public AdminShowReplicaDistributionStmt(TableRef tblRef) {
public ShowReplicaDistributionStmt(TableRef tblRef) {
this.tblRef = tblRef;
}

View File

@ -36,7 +36,7 @@ import com.google.common.collect.Lists;
import java.util.List;
public class AdminShowReplicaStatusStmt extends ShowStmt {
public class ShowReplicaStatusStmt extends ShowStmt {
public static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>()
.add("TabletId").add("ReplicaId").add("BackendId").add("Version").add("LastFailedVersion")
.add("LastSuccessVersion").add("CommittedVersion").add("SchemaHash").add("VersionNum")
@ -50,7 +50,7 @@ public class AdminShowReplicaStatusStmt extends ShowStmt {
private Operator op;
private ReplicaStatus statusFilter;
public AdminShowReplicaStatusStmt(TableRef tblRef, Expr where) {
public ShowReplicaStatusStmt(TableRef tblRef, Expr where) {
this.tblRef = tblRef;
this.where = where;
}

View File

@ -27,10 +27,10 @@ import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.ShowResultSetMetaData;
public class AdminShowTabletStorageFormatStmt extends ShowStmt {
public class ShowTabletStorageFormatStmt extends ShowStmt {
private boolean verbose;
public AdminShowTabletStorageFormatStmt(boolean verbose) {
public ShowTabletStorageFormatStmt(boolean verbose) {
this.verbose = verbose;
}
@ -54,7 +54,7 @@ public class AdminShowTabletStorageFormatStmt extends ShowStmt {
@Override
public String toSql() {
StringBuilder sb = new StringBuilder("ADMIN SHOW TABLET STORAGE TYPE");
StringBuilder sb = new StringBuilder("SHOW TABLET STORAGE TYPE");
if (verbose) {
sb.append(" VERBOSE");
}

View File

@ -17,11 +17,11 @@
package org.apache.doris.catalog;
import org.apache.doris.analysis.AdminShowReplicaDistributionStmt;
import org.apache.doris.analysis.AdminShowReplicaStatusStmt;
import org.apache.doris.analysis.BinaryPredicate.Operator;
import org.apache.doris.analysis.PartitionNames;
import org.apache.doris.analysis.ShowDataSkewStmt;
import org.apache.doris.analysis.ShowReplicaDistributionStmt;
import org.apache.doris.analysis.ShowReplicaStatusStmt;
import org.apache.doris.catalog.MaterializedIndex.IndexExtState;
import org.apache.doris.catalog.Replica.ReplicaStatus;
import org.apache.doris.common.DdlException;
@ -39,7 +39,7 @@ import java.util.Map;
public class MetadataViewer {
public static List<List<String>> getTabletStatus(AdminShowReplicaStatusStmt stmt) throws DdlException {
public static List<List<String>> getTabletStatus(ShowReplicaStatusStmt stmt) throws DdlException {
return getTabletStatus(stmt.getDbName(), stmt.getTblName(), stmt.getPartitions(),
stmt.getStatusFilter(), stmt.getOp());
}
@ -155,7 +155,7 @@ public class MetadataViewer {
}
}
public static List<List<String>> getTabletDistribution(AdminShowReplicaDistributionStmt stmt) throws DdlException {
public static List<List<String>> getTabletDistribution(ShowReplicaDistributionStmt stmt) throws DdlException {
return getTabletDistribution(stmt.getDbName(), stmt.getTblName(), stmt.getPartitionNames());
}

View File

@ -18,12 +18,8 @@
package org.apache.doris.qe;
import org.apache.doris.analysis.AdminCopyTabletStmt;
import org.apache.doris.analysis.AdminDiagnoseTabletStmt;
import org.apache.doris.analysis.AdminShowConfigStmt;
import org.apache.doris.analysis.AdminShowReplicaDistributionStmt;
import org.apache.doris.analysis.AdminShowReplicaStatusStmt;
import org.apache.doris.analysis.AdminShowTabletStorageFormatStmt;
import org.apache.doris.analysis.DescribeStmt;
import org.apache.doris.analysis.DiagnoseTabletStmt;
import org.apache.doris.analysis.Expr;
import org.apache.doris.analysis.HelpStmt;
import org.apache.doris.analysis.LimitElement;
@ -42,6 +38,7 @@ import org.apache.doris.analysis.ShowCollationStmt;
import org.apache.doris.analysis.ShowColumnHistStmt;
import org.apache.doris.analysis.ShowColumnStatsStmt;
import org.apache.doris.analysis.ShowColumnStmt;
import org.apache.doris.analysis.ShowConfigStmt;
import org.apache.doris.analysis.ShowConvertLSCStmt;
import org.apache.doris.analysis.ShowCreateCatalogStmt;
import org.apache.doris.analysis.ShowCreateDbStmt;
@ -77,6 +74,8 @@ import org.apache.doris.analysis.ShowProcStmt;
import org.apache.doris.analysis.ShowProcesslistStmt;
import org.apache.doris.analysis.ShowQueryProfileStmt;
import org.apache.doris.analysis.ShowQueryStatsStmt;
import org.apache.doris.analysis.ShowReplicaDistributionStmt;
import org.apache.doris.analysis.ShowReplicaStatusStmt;
import org.apache.doris.analysis.ShowRepositoriesStmt;
import org.apache.doris.analysis.ShowResourcesStmt;
import org.apache.doris.analysis.ShowRestoreStmt;
@ -96,6 +95,7 @@ import org.apache.doris.analysis.ShowTableStatsStmt;
import org.apache.doris.analysis.ShowTableStatusStmt;
import org.apache.doris.analysis.ShowTableStmt;
import org.apache.doris.analysis.ShowTabletStmt;
import org.apache.doris.analysis.ShowTabletStorageFormatStmt;
import org.apache.doris.analysis.ShowTabletsBelongStmt;
import org.apache.doris.analysis.ShowTransactionStmt;
import org.apache.doris.analysis.ShowTrashDiskStmt;
@ -370,11 +370,11 @@ public class ShowExecutor {
handleShowTrash();
} else if (stmt instanceof ShowTrashDiskStmt) {
handleShowTrashDisk();
} else if (stmt instanceof AdminShowReplicaStatusStmt) {
} else if (stmt instanceof ShowReplicaStatusStmt) {
handleAdminShowTabletStatus();
} else if (stmt instanceof AdminShowReplicaDistributionStmt) {
} else if (stmt instanceof ShowReplicaDistributionStmt) {
handleAdminShowTabletDistribution();
} else if (stmt instanceof AdminShowConfigStmt) {
} else if (stmt instanceof ShowConfigStmt) {
handleAdminShowConfig();
} else if (stmt instanceof ShowSmallFilesStmt) {
handleShowSmallFiles();
@ -408,9 +408,9 @@ public class ShowExecutor {
handleShowTableCreation();
} else if (stmt instanceof ShowLastInsertStmt) {
handleShowLastInsert();
} else if (stmt instanceof AdminShowTabletStorageFormatStmt) {
} else if (stmt instanceof ShowTabletStorageFormatStmt) {
handleAdminShowTabletStorageFormat();
} else if (stmt instanceof AdminDiagnoseTabletStmt) {
} else if (stmt instanceof DiagnoseTabletStmt) {
handleAdminDiagnoseTablet();
} else if (stmt instanceof ShowCreateMaterializedViewStmt) {
handleShowCreateMaterializedView();
@ -2107,7 +2107,7 @@ public class ShowExecutor {
}
private void handleAdminShowTabletStatus() throws AnalysisException {
AdminShowReplicaStatusStmt showStmt = (AdminShowReplicaStatusStmt) stmt;
ShowReplicaStatusStmt showStmt = (ShowReplicaStatusStmt) stmt;
List<List<String>> results;
try {
results = MetadataViewer.getTabletStatus(showStmt);
@ -2118,7 +2118,7 @@ public class ShowExecutor {
}
private void handleAdminShowTabletDistribution() throws AnalysisException {
AdminShowReplicaDistributionStmt showStmt = (AdminShowReplicaDistributionStmt) stmt;
ShowReplicaDistributionStmt showStmt = (ShowReplicaDistributionStmt) stmt;
List<List<String>> results;
try {
results = MetadataViewer.getTabletDistribution(showStmt);
@ -2129,7 +2129,7 @@ public class ShowExecutor {
}
private void handleAdminShowConfig() throws AnalysisException {
AdminShowConfigStmt showStmt = (AdminShowConfigStmt) stmt;
ShowConfigStmt showStmt = (ShowConfigStmt) stmt;
List<List<String>> results;
PatternMatcher matcher = null;
@ -2605,7 +2605,7 @@ public class ShowExecutor {
}
private void handleAdminDiagnoseTablet() {
AdminDiagnoseTabletStmt showStmt = (AdminDiagnoseTabletStmt) stmt;
DiagnoseTabletStmt showStmt = (DiagnoseTabletStmt) stmt;
List<List<String>> resultRowSet = Diagnoser.diagnoseTablet(showStmt.getTabletId());
ShowResultSetMetaData showMetaData = showStmt.getMetaData();
resultSet = new ShowResultSet(showMetaData, resultRowSet);

View File

@ -193,6 +193,7 @@ import org.apache.doris.qe.SqlModeHelper;
keywordMap.put("desc", new Integer(SqlParserSymbols.KW_DESC));
keywordMap.put("describe", new Integer(SqlParserSymbols.KW_DESCRIBE));
keywordMap.put("diagnose", new Integer(SqlParserSymbols.KW_DIAGNOSE));
keywordMap.put("diagnosis", new Integer(SqlParserSymbols.KW_DIAGNOSIS));
keywordMap.put("disk", new Integer(SqlParserSymbols.KW_DISK));
keywordMap.put("distinct", new Integer(SqlParserSymbols.KW_DISTINCT));
keywordMap.put("distinctpc", new Integer(SqlParserSymbols.KW_DISTINCTPC));

View File

@ -35,7 +35,7 @@ import org.junit.jupiter.api.Test;
import java.io.StringReader;
import java.lang.reflect.Method;
public class AdminShowReplicaTest extends TestWithFeService {
public class ShowReplicaTest extends TestWithFeService {
@Override
protected void runBeforeAll() throws Exception {
createDatabase("test");
@ -51,8 +51,8 @@ public class AdminShowReplicaTest extends TestWithFeService {
@Test
public void testShowReplicaDistribution() throws Exception {
String stmtStr = "admin show replica distribution from test.tbl1 partition(p1)";
AdminShowReplicaDistributionStmt stmt = (AdminShowReplicaDistributionStmt) parseAndAnalyzeStmt(
String stmtStr = "show replica distribution from test.tbl1 partition(p1)";
ShowReplicaDistributionStmt stmt = (ShowReplicaDistributionStmt) parseAndAnalyzeStmt(
stmtStr);
ShowExecutor executor = new ShowExecutor(connectContext, stmt);
ShowResultSet resultSet = executor.execute();
@ -93,36 +93,36 @@ public class AdminShowReplicaTest extends TestWithFeService {
@Test
public void testShowReplicaStatus() {
String stmt = new String("ADMIN SHOW REPLICA STATUS FROM db.tbl1 WHERE status = 'ok'");
String stmt = new String("SHOW REPLICA STATUS FROM db.tbl1 WHERE status = 'ok'");
testAnalyzeWhere(stmt, true);
stmt = new String("ADMIN SHOW REPLICA STATUS FROM db.tbl1 WHERE status != 'ok'");
stmt = new String("SHOW REPLICA STATUS FROM db.tbl1 WHERE status != 'ok'");
testAnalyzeWhere(stmt, true);
stmt = new String("ADMIN SHOW REPLICA STATUS FROM db.tbl1 WHERE status = 'dead'");
stmt = new String("SHOW REPLICA STATUS FROM db.tbl1 WHERE status = 'dead'");
testAnalyzeWhere(stmt, true);
stmt = new String("ADMIN SHOW REPLICA STATUS FROM db.tbl1 WHERE status != 'VERSION_ERROR'");
stmt = new String("SHOW REPLICA STATUS FROM db.tbl1 WHERE status != 'VERSION_ERROR'");
testAnalyzeWhere(stmt, true);
stmt = new String("ADMIN SHOW REPLICA STATUS FROM db.tbl1 WHERE status = 'MISSING'");
stmt = new String("SHOW REPLICA STATUS FROM db.tbl1 WHERE status = 'MISSING'");
testAnalyzeWhere(stmt, true);
stmt = new String("ADMIN SHOW REPLICA STATUS FROM db.tbl1 WHERE status = 'missing'");
stmt = new String("SHOW REPLICA STATUS FROM db.tbl1 WHERE status = 'missing'");
testAnalyzeWhere(stmt, true);
stmt = new String("ADMIN SHOW REPLICA STATUS FROM db.tbl1 WHERE status != 'what'");
stmt = new String("SHOW REPLICA STATUS FROM db.tbl1 WHERE status != 'what'");
testAnalyzeWhere(stmt, false);
stmt = new String("ADMIN SHOW REPLICA STATUS FROM db.tbl1 WHERE status = 'how'");
stmt = new String("SHOW REPLICA STATUS FROM db.tbl1 WHERE status = 'how'");
testAnalyzeWhere(stmt, false);
}
private void testAnalyzeWhere(String stmt, boolean correct) {
SqlParser parser = new SqlParser(new SqlScanner(new StringReader(stmt)));
AdminShowReplicaStatusStmt showStmt = null;
ShowReplicaStatusStmt showStmt = null;
try {
showStmt = (AdminShowReplicaStatusStmt) SqlParserUtils.getFirstStmt(parser);
showStmt = (ShowReplicaStatusStmt) SqlParserUtils.getFirstStmt(parser);
} catch (Error e) {
Assert.fail(e.getMessage());
} catch (Exception e) {
@ -130,7 +130,7 @@ public class AdminShowReplicaTest extends TestWithFeService {
}
try {
Method method = AdminShowReplicaStatusStmt.class.getDeclaredMethod("analyzeWhere");
Method method = ShowReplicaStatusStmt.class.getDeclaredMethod("analyzeWhere");
method.setAccessible(true);
if (!(Boolean) method.invoke(showStmt)) {
if (correct) {