[Enhancement](planner) Support string input for sql_select_limit (#34177)

This commit is contained in:
zy-kkk
2024-04-27 01:34:35 +08:00
committed by yiguolei
parent 414fbd353e
commit c998e2f714
2 changed files with 37 additions and 0 deletions

View File

@ -48,6 +48,8 @@ public class VariableVarConverters {
converters.put(SessionVariable.RUNTIME_FILTER_TYPE, runtimeFilterTypeConverter);
ValidatePasswordPolicyConverter validatePasswordPolicyConverter = new ValidatePasswordPolicyConverter();
converters.put(GlobalVariable.VALIDATE_PASSWORD_POLICY, validatePasswordPolicyConverter);
SqlSelectLimitConverter sqlSelectLimitConverter = new SqlSelectLimitConverter();
converters.put(SessionVariable.SQL_SELECT_LIMIT, sqlSelectLimitConverter);
}
public static Boolean hasConverter(String varName) {
@ -96,6 +98,27 @@ public class VariableVarConverters {
}
}
// Converter to convert sql select limit variable
public static class SqlSelectLimitConverter implements VariableVarConverterI {
@Override
public Long encode(String value) throws DdlException {
if (value.equalsIgnoreCase("DEFAULT")) {
return Long.MAX_VALUE;
} else {
try {
return Long.parseLong(value);
} catch (NumberFormatException e) {
throw new DdlException("Invalid sql_select_limit value: " + value);
}
}
}
@Override
public String decode(Long value) throws DdlException {
return String.valueOf(value);
}
}
public static class ValidatePasswordPolicyConverter implements VariableVarConverterI {
@Override
public Long encode(String value) throws DdlException {