[Enhancement](Error Msg) show details of COLUMN and TABLE name regex #11999
Co-authored-by: wuhangze <wuhangze@jd.com>
This commit is contained in:
@ -79,7 +79,8 @@ public class AddRollupClause extends AlterTableClause {
|
||||
Set<String> colSet = Sets.newHashSet();
|
||||
for (String col : columnNames) {
|
||||
if (Strings.isNullOrEmpty(col)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME, col);
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME,
|
||||
col, FeNameFormat.getColumnNameRegex());
|
||||
}
|
||||
if (!colSet.add(col)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_DUP_FIELDNAME, col);
|
||||
|
||||
@ -24,6 +24,7 @@ import org.apache.doris.catalog.Table;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.ErrorCode;
|
||||
import org.apache.doris.common.ErrorReport;
|
||||
import org.apache.doris.common.FeNameFormat;
|
||||
import org.apache.doris.common.UserException;
|
||||
import org.apache.doris.common.util.PrintableMap;
|
||||
import org.apache.doris.common.util.Util;
|
||||
@ -142,7 +143,8 @@ public class AlterColumnStatsStmt extends DdlStmt {
|
||||
|
||||
OlapTable olapTable = (OlapTable) table;
|
||||
if (olapTable.getColumn(columnName) == null) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME, columnName);
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME,
|
||||
columnName, FeNameFormat.getColumnNameRegex());
|
||||
}
|
||||
|
||||
if (optPartitionNames != null) {
|
||||
|
||||
@ -27,6 +27,7 @@ import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.ErrorCode;
|
||||
import org.apache.doris.common.ErrorReport;
|
||||
import org.apache.doris.common.FeNameFormat;
|
||||
import org.apache.doris.common.UserException;
|
||||
import org.apache.doris.common.util.PrintableMap;
|
||||
import org.apache.doris.common.util.Util;
|
||||
@ -217,7 +218,8 @@ public class AnalyzeStmt extends DdlStmt {
|
||||
.filter(entity -> !baseSchema.contains(entity)).findFirst();
|
||||
if (optional.isPresent()) {
|
||||
String columnName = optional.get();
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME, columnName);
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME,
|
||||
columnName, FeNameFormat.getColumnNameRegex());
|
||||
}
|
||||
} finally {
|
||||
table.readUnlock();
|
||||
|
||||
@ -21,6 +21,7 @@ import org.apache.doris.alter.AlterOpType;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.ErrorCode;
|
||||
import org.apache.doris.common.ErrorReport;
|
||||
import org.apache.doris.common.FeNameFormat;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
@ -51,7 +52,8 @@ public class DropColumnClause extends AlterTableClause {
|
||||
@Override
|
||||
public void analyze(Analyzer analyzer) throws AnalysisException {
|
||||
if (Strings.isNullOrEmpty(colName)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME, colName);
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME,
|
||||
colName, FeNameFormat.getColumnNameRegex());
|
||||
}
|
||||
if (Strings.isNullOrEmpty(rollupName)) {
|
||||
rollupName = null;
|
||||
|
||||
@ -153,7 +153,7 @@ public enum ErrorCode {
|
||||
ERR_TABLE_NOT_LOCKED(1100, new byte[]{'H', 'Y', '0', '0', '0'}, "Table '%s' was not locked with LOCK TABLES"),
|
||||
ERR_UNUSED_17(1101, new byte[]{}, "You should never see it"),
|
||||
ERR_WRONG_DB_NAME(1102, new byte[]{'4', '2', '0', '0', '0'}, "Incorrect database name '%s'"),
|
||||
ERR_WRONG_TABLE_NAME(1103, new byte[]{'4', '2', '0', '0', '0'}, "Incorrect table name '%s'"),
|
||||
ERR_WRONG_TABLE_NAME(1103, new byte[]{'4', '2', '0', '0', '0'}, "Incorrect table name '%s'. Table name regex is '%s'"),
|
||||
ERR_TOO_BIG_SELECT(1104, new byte[]{'4', '2', '0', '0', '0'}, "The SELECT would examine more than MAX_JOIN_SIZE "
|
||||
+ "rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay"),
|
||||
ERR_UNKNOWN_ERROR(1105, new byte[]{'H', 'Y', '0', '0', '0'}, "Unknown error"),
|
||||
@ -248,7 +248,7 @@ public enum ErrorCode {
|
||||
+ "support AUTO_INCREMENT columns"),
|
||||
ERR_DELAYED_INSERT_TABLE_LOCKED(1165, new byte[]{'H', 'Y', '0', '0', '0'}, "INSERT DELAYED can't be used with "
|
||||
+ "table '%s' because it is locked with LOCK TABLES"),
|
||||
ERR_WRONG_COLUMN_NAME(1166, new byte[]{'4', '2', '0', '0', '0'}, "Incorrect column name '%s'"),
|
||||
ERR_WRONG_COLUMN_NAME(1166, new byte[]{'4', '2', '0', '0', '0'}, "Incorrect column name '%s'. Column regex is '%s'"),
|
||||
ERR_WRONG_KEY_COLUMN(1167, new byte[]{'4', '2', '0', '0', '0'}, "The used storage engine can't index column '%s'"),
|
||||
ERR_WRONG_MRG_TABLE(1168, new byte[]{'H', 'Y', '0', '0', '0'}, "Unable to open underlying table which is "
|
||||
+ "differently defined or of non-MyISAM type or doesn't exist"),
|
||||
|
||||
@ -60,7 +60,8 @@ public class FeNameFormat {
|
||||
if (Strings.isNullOrEmpty(tableName)
|
||||
|| !tableName.matches(COMMON_TABLE_NAME_REGEX)
|
||||
|| tableName.length() > Config.table_name_length_limit) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_TABLE_NAME, tableName);
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_TABLE_NAME, tableName,
|
||||
COMMON_TABLE_NAME_REGEX);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,10 +77,12 @@ public class FeNameFormat {
|
||||
|
||||
public static void checkColumnName(String columnName) throws AnalysisException {
|
||||
if (Strings.isNullOrEmpty(columnName) || !columnName.matches(COLUMN_NAME_REGEX)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME, columnName);
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME,
|
||||
columnName, FeNameFormat.COLUMN_NAME_REGEX);
|
||||
}
|
||||
if (columnName.startsWith(SchemaChangeHandler.SHADOW_NAME_PRFIX)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME, columnName);
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME,
|
||||
columnName, FeNameFormat.COLUMN_NAME_REGEX);
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,4 +134,8 @@ public class FeNameFormat {
|
||||
throw new AnalysisException("All the external catalog should contain the type property.");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getColumnNameRegex() {
|
||||
return COLUMN_NAME_REGEX;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ import org.apache.doris.catalog.Type;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.ErrorCode;
|
||||
import org.apache.doris.common.ErrorReport;
|
||||
import org.apache.doris.common.FeNameFormat;
|
||||
import org.apache.doris.common.Pair;
|
||||
import org.apache.doris.common.util.DebugUtil;
|
||||
import org.apache.doris.common.util.ListComparator;
|
||||
@ -347,7 +348,8 @@ public class PartitionsProcDir implements ProcDirInterface {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME, columnName);
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME,
|
||||
columnName, FeNameFormat.getColumnNameRegex());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user