diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/NereidsParser.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/NereidsParser.java index 3699f26578f929..4890ddd214d5ae 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/NereidsParser.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/NereidsParser.java @@ -36,6 +36,7 @@ import org.apache.doris.qe.ConnectContext; import org.apache.doris.qe.SessionVariable; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.antlr.v4.runtime.CharStreams; @@ -67,6 +68,8 @@ public class NereidsParser { private static final BitSet EXPLAIN_TOKENS = new BitSet(); + private static final Map LITERAL_TOKENS; + static { EXPLAIN_TOKENS.set(DorisLexer.EXPLAIN); EXPLAIN_TOKENS.set(DorisLexer.PARSED); @@ -78,6 +81,14 @@ public class NereidsParser { EXPLAIN_TOKENS.set(DorisLexer.PLAN); EXPLAIN_TOKENS.set(DorisLexer.PROCESS); + ImmutableMap.Builder literalToTokenType = ImmutableMap.builder(); + for (int tokenType = 0; tokenType <= DorisLexer.VOCABULARY.getMaxTokenType(); tokenType++) { + String literalName = DorisLexer.VOCABULARY.getLiteralName(tokenType); + if (literalName != null) { + literalToTokenType.put(literalName.substring(1, literalName.length() - 1), tokenType); + } + } + LITERAL_TOKENS = literalToTokenType.build(); } /** @@ -264,7 +275,7 @@ public Expression parseExpression(String expression) { } private boolean isSimpleIdentifier(String expression) { - if (expression == null || expression.length() == 0) { + if (expression == null || expression.isEmpty()) { return false; } @@ -277,7 +288,7 @@ private boolean isSimpleIdentifier(String expression) { return false; } } - return hasLetter; + return hasLetter && !LITERAL_TOKENS.containsKey(expression.toUpperCase()); } public DataType parseDataType(String dataType) {