[improvement](outfile)support underscore prefix when select outfile (#25395)
This commit is contained in:
@ -577,7 +577,7 @@ public class OutFileClause {
|
||||
|
||||
if (properties.containsKey(PROP_SUCCESS_FILE_NAME)) {
|
||||
successFileName = properties.get(PROP_SUCCESS_FILE_NAME);
|
||||
FeNameFormat.checkCommonName("file name", successFileName);
|
||||
FeNameFormat.checkOutfileSuccessFileName("file name", successFileName);
|
||||
processedPropKeys.add(PROP_SUCCESS_FILE_NAME);
|
||||
}
|
||||
|
||||
|
||||
@ -30,12 +30,14 @@ import com.google.common.base.Strings;
|
||||
public class FeNameFormat {
|
||||
private static final String LABEL_REGEX = "^[-_A-Za-z0-9:]{1,128}$";
|
||||
private static final String COMMON_NAME_REGEX = "^[a-zA-Z][a-zA-Z0-9-_]{0,63}$";
|
||||
private static final String UNDERSCORE_COMMON_NAME_REGEX = "^[_a-zA-Z][a-zA-Z0-9-_]{0,63}$";
|
||||
private static final String TABLE_NAME_REGEX = "^[a-zA-Z][a-zA-Z0-9-_]*$";
|
||||
private static final String USER_NAME_REGEX = "^[a-zA-Z][a-zA-Z0-9.-_]*$";
|
||||
private static final String COLUMN_NAME_REGEX = "^[_a-zA-Z@0-9\\s<>/][.a-zA-Z0-9_+-/><?@#$%^&*\"\\s,:]{0,255}$";
|
||||
|
||||
private static final String UNICODE_LABEL_REGEX = "^[-_A-Za-z0-9:\\p{L}]{1,128}$";
|
||||
private static final String UNICODE_COMMON_NAME_REGEX = "^[a-zA-Z\\p{L}][a-zA-Z0-9-_\\p{L}]{0,63}$";
|
||||
private static final String UNICODE_UNDERSCORE_COMMON_NAME_REGEX = "^[_a-zA-Z\\p{L}][a-zA-Z0-9-_\\p{L}]{0,63}$";
|
||||
private static final String UNICODE_TABLE_NAME_REGEX = "^[a-zA-Z\\p{L}][a-zA-Z0-9-_\\p{L}]*$";
|
||||
private static final String UNICODE_USER_NAME_REGEX = "^[a-zA-Z\\p{L}][a-zA-Z0-9.-_\\p{L}]*$";
|
||||
private static final String UNICODE_COLUMN_NAME_REGEX
|
||||
@ -138,6 +140,12 @@ public class FeNameFormat {
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkOutfileSuccessFileName(String type, String name) throws AnalysisException {
|
||||
if (Strings.isNullOrEmpty(name) || !name.matches(getOutfileSuccessFileNameRegex())) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_NAME_FORMAT, type, name);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isEnableUnicodeNameSupport() {
|
||||
boolean unicodeSupport;
|
||||
if (ConnectContext.get() != null) {
|
||||
@ -187,4 +195,12 @@ public class FeNameFormat {
|
||||
return COMMON_NAME_REGEX;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getOutfileSuccessFileNameRegex() {
|
||||
if (FeNameFormat.isEnableUnicodeNameSupport()) {
|
||||
return UNICODE_UNDERSCORE_COMMON_NAME_REGEX;
|
||||
} else {
|
||||
return UNDERSCORE_COMMON_NAME_REGEX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,6 +55,9 @@ public class FeNameFormatTest {
|
||||
ExceptionChecker.expectThrows(AnalysisException.class, () -> FeNameFormat.checkCommonName("fakeType", "_commonName"));
|
||||
ExceptionChecker.expectThrowsNoException(() -> FeNameFormat.checkCommonName("fakeType", "common-Name"));
|
||||
ExceptionChecker.expectThrowsNoException(() -> FeNameFormat.checkCommonName("fakeType", "commonName-"));
|
||||
|
||||
// check success file name prefix
|
||||
ExceptionChecker.expectThrowsNoException(() -> FeNameFormat.checkOutfileSuccessFileName("fakeType", "_success"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user