pick from master #37720 support hint use parameter without key, like: ```sql SELECT /*+ query_timeout(3000) */ * FROM t; ```
This commit is contained in:
@ -3101,24 +3101,28 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
|
||||
case "set_var":
|
||||
Map<String, Optional<String>> parameters = Maps.newLinkedHashMap();
|
||||
for (HintAssignmentContext kv : hintStatement.parameters) {
|
||||
String parameterName = visitIdentifierOrText(kv.key);
|
||||
Optional<String> value = Optional.empty();
|
||||
if (kv.constantValue != null) {
|
||||
Literal literal = (Literal) visit(kv.constantValue);
|
||||
value = Optional.ofNullable(literal.toLegacyLiteral().getStringValue());
|
||||
} else if (kv.identifierValue != null) {
|
||||
// maybe we should throw exception when the identifierValue is quoted identifier
|
||||
value = Optional.ofNullable(kv.identifierValue.getText());
|
||||
if (kv.key != null) {
|
||||
String parameterName = visitIdentifierOrText(kv.key);
|
||||
Optional<String> value = Optional.empty();
|
||||
if (kv.constantValue != null) {
|
||||
Literal literal = (Literal) visit(kv.constantValue);
|
||||
value = Optional.ofNullable(literal.toLegacyLiteral().getStringValue());
|
||||
} else if (kv.identifierValue != null) {
|
||||
// maybe we should throw exception when the identifierValue is quoted identifier
|
||||
value = Optional.ofNullable(kv.identifierValue.getText());
|
||||
}
|
||||
parameters.put(parameterName, value);
|
||||
}
|
||||
parameters.put(parameterName, value);
|
||||
}
|
||||
hints.put(hintName, new SelectHintSetVar(hintName, parameters));
|
||||
break;
|
||||
case "leading":
|
||||
List<String> leadingParameters = new ArrayList<String>();
|
||||
for (HintAssignmentContext kv : hintStatement.parameters) {
|
||||
String parameterName = visitIdentifierOrText(kv.key);
|
||||
leadingParameters.add(parameterName);
|
||||
if (kv.key != null) {
|
||||
String parameterName = visitIdentifierOrText(kv.key);
|
||||
leadingParameters.add(parameterName);
|
||||
}
|
||||
}
|
||||
hints.put(hintName, new SelectHintLeading(hintName, leadingParameters));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user