From 14b0a4738f4afcc6e018d4bd05d3b632b919d590 Mon Sep 17 00:00:00 2001 From: wyb Date: Mon, 2 Sep 2024 18:41:33 +0800 Subject: [PATCH] Fix comment Signed-off-by: wyb --- .../com/starrocks/common/FeConstants.java | 3 +++ .../common/proc/IndexSchemaProcNode.java | 3 ++- .../connector/jdbc/JDBCSchemaResolver.java | 3 ++- .../connector/jdbc/OracleSchemaResolver.java | 3 ++- .../jdbc/PostgresSchemaResolver.java | 3 ++- .../java/com/starrocks/mysql/MysqlProto.java | 3 ++- .../java/com/starrocks/qe/ShowExecutor.java | 21 ++++++++++++------- .../sql/analyzer/ShowStmtAnalyzer.java | 7 ++++--- 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/fe/fe-core/src/main/java/com/starrocks/common/FeConstants.java b/fe/fe-core/src/main/java/com/starrocks/common/FeConstants.java index e11f12954e4c1d..c3d08500283121 100644 --- a/fe/fe-core/src/main/java/com/starrocks/common/FeConstants.java +++ b/fe/fe-core/src/main/java/com/starrocks/common/FeConstants.java @@ -100,6 +100,9 @@ public class FeConstants { public static final int DEFAULT_UNPARTITIONED_TABLE_BUCKET_NUM = 16; + public static final String YES = "YES"; + public static final String NO = "NO"; + public static final String DOCUMENT_SHOW_ALTER = "https://docs.starrocks.io/docs/sql-reference/sql-statements/data-manipulation/SHOW_ALTER"; public static final String DOCUMENT_SHOW_ALTER_MATERIALIZED_VIEW = diff --git a/fe/fe-core/src/main/java/com/starrocks/common/proc/IndexSchemaProcNode.java b/fe/fe-core/src/main/java/com/starrocks/common/proc/IndexSchemaProcNode.java index c35c55281061f0..6c5c9d52997af0 100644 --- a/fe/fe-core/src/main/java/com/starrocks/common/proc/IndexSchemaProcNode.java +++ b/fe/fe-core/src/main/java/com/starrocks/common/proc/IndexSchemaProcNode.java @@ -39,6 +39,7 @@ import com.google.common.collect.Lists; import com.starrocks.catalog.Column; import com.starrocks.common.AnalysisException; +import com.starrocks.common.FeConstants; import org.apache.commons.lang.StringUtils; import java.util.Arrays; @@ -94,7 +95,7 @@ public ProcResult fetchResult() throws AnalysisException { List rowList = Arrays.asList(column.getName(), column.getType().canonicalName().toLowerCase(), - column.isAllowNull() ? "YES" : "NO", + column.isAllowNull() ? FeConstants.YES : FeConstants.NO, ((Boolean) column.isKey()).toString(), defaultStr, extraStr); diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/JDBCSchemaResolver.java b/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/JDBCSchemaResolver.java index 2d19e926c64d86..3d7ff4d6e4f270 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/JDBCSchemaResolver.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/JDBCSchemaResolver.java @@ -22,6 +22,7 @@ import com.starrocks.catalog.Table; import com.starrocks.catalog.Type; import com.starrocks.common.DdlException; +import com.starrocks.common.FeConstants; import com.starrocks.connector.exception.StarRocksConnectorException; import java.sql.Connection; @@ -99,7 +100,7 @@ public List convertToSRTable(ResultSet columnSet) throws SQLException { } catch (SQLException ignored) { } fullSchema.add(new Column(columnSet.getString("COLUMN_NAME"), type, - columnSet.getString("IS_NULLABLE").equals("YES"), comment)); + columnSet.getString("IS_NULLABLE").equals(FeConstants.YES), comment)); } return fullSchema; } diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/OracleSchemaResolver.java b/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/OracleSchemaResolver.java index d52f4636d9e32f..045da2bc35dd41 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/OracleSchemaResolver.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/OracleSchemaResolver.java @@ -22,6 +22,7 @@ import com.starrocks.catalog.Table; import com.starrocks.catalog.Type; import com.starrocks.common.DdlException; +import com.starrocks.common.FeConstants; import java.sql.Connection; import java.sql.ResultSet; @@ -56,7 +57,7 @@ public List convertToSRTable(ResultSet columnSet) throws SQLException { columnSet.getInt("DECIMAL_DIGITS")); String columnName = columnSet.getString("COLUMN_NAME"); fullSchema.add(new Column(columnName, type, - columnSet.getString("IS_NULLABLE").equals("YES"))); + columnSet.getString("IS_NULLABLE").equals(FeConstants.YES))); } return fullSchema; } diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/PostgresSchemaResolver.java b/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/PostgresSchemaResolver.java index 380422b10e69ce..675a6d920b1956 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/PostgresSchemaResolver.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/PostgresSchemaResolver.java @@ -23,6 +23,7 @@ import com.starrocks.catalog.Table; import com.starrocks.catalog.Type; import com.starrocks.common.DdlException; +import com.starrocks.common.FeConstants; import com.starrocks.common.util.TimeUtils; import java.sql.Connection; @@ -61,7 +62,7 @@ public List convertToSRTable(ResultSet columnSet) throws SQLException { columnName = "\"" + columnName + "\""; } fullSchema.add(new Column(columnName, type, - columnSet.getString("IS_NULLABLE").equals("YES"))); + columnSet.getString("IS_NULLABLE").equals(FeConstants.YES))); } return fullSchema; } diff --git a/fe/fe-core/src/main/java/com/starrocks/mysql/MysqlProto.java b/fe/fe-core/src/main/java/com/starrocks/mysql/MysqlProto.java index 4f90762120813e..1e3e1d217d1af0 100644 --- a/fe/fe-core/src/main/java/com/starrocks/mysql/MysqlProto.java +++ b/fe/fe-core/src/main/java/com/starrocks/mysql/MysqlProto.java @@ -41,6 +41,7 @@ import com.starrocks.common.DdlException; import com.starrocks.common.ErrorCode; import com.starrocks.common.ErrorReport; +import com.starrocks.common.FeConstants; import com.starrocks.qe.ConnectContext; import com.starrocks.server.GlobalStateMgr; import com.starrocks.sql.ast.UserIdentity; @@ -62,7 +63,7 @@ public class MysqlProto { // randomString: data send by server in plug-in data field // user_name#HIGH@cluster_name private static boolean authenticate(ConnectContext context, byte[] scramble, byte[] randomString, String user) { - String usePasswd = scramble.length == 0 ? "NO" : "YES"; + String usePasswd = scramble.length == 0 ? FeConstants.NO : FeConstants.YES; if (user == null || user.isEmpty()) { ErrorReport.report(ErrorCode.ERR_AUTHENTICATION_FAIL, "", usePasswd); diff --git a/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java b/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java index 1a088ad6b4ffd3..4455d9d5b30bc8 100644 --- a/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java +++ b/fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java @@ -83,6 +83,7 @@ import com.starrocks.common.DdlException; import com.starrocks.common.ErrorCode; import com.starrocks.common.ErrorReport; +import com.starrocks.common.FeConstants; import com.starrocks.common.MetaNotFoundException; import com.starrocks.common.Pair; import com.starrocks.common.PatternMatcher; @@ -880,12 +881,16 @@ public ShowResultSet visitShowResourceGroupUsageStatement(ShowResourceGroupUsage @Override public ShowResultSet visitShowEnginesStatement(ShowEnginesStmt statement, ConnectContext context) { List> rowSet = Lists.newArrayList(); - rowSet.add(Lists.newArrayList("OLAP", "YES", "Default storage engine of StarRocks", "NO", "NO", "NO")); - rowSet.add(Lists.newArrayList("MySQL", "YES", "MySQL server which data is in it", "NO", "NO", "NO")); - rowSet.add(Lists.newArrayList("ELASTICSEARCH", "YES", "ELASTICSEARCH cluster which data is in it", "NO", "NO", - "NO")); - rowSet.add(Lists.newArrayList("HIVE", "YES", "HIVE database which data is in it", "NO", "NO", "NO")); - rowSet.add(Lists.newArrayList("ICEBERG", "YES", "ICEBERG data lake which data is in it", "NO", "NO", "NO")); + rowSet.add(Lists.newArrayList("OLAP", FeConstants.YES, "Default storage engine of StarRocks", FeConstants.NO, + FeConstants.NO, FeConstants.NO)); + rowSet.add(Lists.newArrayList("MySQL", FeConstants.YES, "MySQL server which data is in it", FeConstants.NO, + FeConstants.NO, FeConstants.NO)); + rowSet.add(Lists.newArrayList("ELASTICSEARCH", FeConstants.YES, "ELASTICSEARCH cluster which data is in it", + FeConstants.NO, FeConstants.NO, FeConstants.NO)); + rowSet.add(Lists.newArrayList("HIVE", FeConstants.YES, "HIVE database which data is in it", FeConstants.NO, + FeConstants.NO, FeConstants.NO)); + rowSet.add(Lists.newArrayList("ICEBERG", FeConstants.YES, "ICEBERG data lake which data is in it", FeConstants.NO, + FeConstants.NO, FeConstants.NO)); // Only success return new ShowResultSet(statement.getMetaData(), rowSet); @@ -1002,8 +1007,8 @@ public ShowResultSet visitShowColumnStatement(ShowColumnStmt statement, ConnectC } final String columnName = col.getName(); final String columnType = col.getType().canonicalName().toLowerCase(); - final String isAllowNull = col.isAllowNull() ? "YES" : "NO"; - final String isKey = col.isKey() ? "YES" : "NO"; + final String isAllowNull = col.isAllowNull() ? FeConstants.YES : FeConstants.NO; + final String isKey = col.isKey() ? FeConstants.YES : FeConstants.NO; String defaultValue = null; if (!col.getType().isOnlyMetricType()) { defaultValue = col.getMetaDefaultValue(Lists.newArrayList()); diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/analyzer/ShowStmtAnalyzer.java b/fe/fe-core/src/main/java/com/starrocks/sql/analyzer/ShowStmtAnalyzer.java index 16c3b76c6bb5ab..c312d38489cf9d 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/analyzer/ShowStmtAnalyzer.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/analyzer/ShowStmtAnalyzer.java @@ -40,6 +40,7 @@ import com.starrocks.common.DdlException; import com.starrocks.common.ErrorCode; import com.starrocks.common.ErrorReport; +import com.starrocks.common.FeConstants; import com.starrocks.common.proc.ExternalTableProcDir; import com.starrocks.common.proc.PartitionsProcDir; import com.starrocks.common.proc.ProcNodeInterface; @@ -351,7 +352,7 @@ private void descTableFunctionTable(DescribeStmt node, ConnectContext context) { List row = Arrays.asList( column.getName(), column.getType().canonicalName().toLowerCase(), - column.isAllowNull() ? "YES" : "NO"); + column.isAllowNull() ? FeConstants.YES : FeConstants.NO); node.getTotalRows().add(row); } } @@ -394,7 +395,7 @@ private void descInternalCatalogTable(DescribeStmt node, ConnectContext context) // If you do not follow this specification, it may cause the BI system, // such as superset, to fail to recognize the column type. column.getType().canonicalName().toLowerCase(), - column.isAllowNull() ? "YES" : "NO", + column.isAllowNull() ? FeConstants.YES : FeConstants.NO, ((Boolean) column.isKey()).toString(), defaultStr, extraStr); @@ -473,7 +474,7 @@ private void descInternalCatalogTable(DescribeStmt node, ConnectContext context) // If you do not follow this specification, it may cause the BI system, // such as superset, to fail to recognize the column type. column.getType().canonicalName().toLowerCase(), - column.isAllowNull() ? "YES" : "NO", + column.isAllowNull() ? FeConstants.YES : FeConstants.NO, ((Boolean) column.isKey()).toString(), defaultStr, extraStr);