Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
924060929 committed Dec 22, 2024
1 parent 3fcfc61 commit e79fb22
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,6 +68,8 @@ public class NereidsParser {

private static final BitSet EXPLAIN_TOKENS = new BitSet();

private static final Map<String, Integer> LITERAL_TOKENS;

static {
EXPLAIN_TOKENS.set(DorisLexer.EXPLAIN);
EXPLAIN_TOKENS.set(DorisLexer.PARSED);
Expand All @@ -78,6 +81,14 @@ public class NereidsParser {
EXPLAIN_TOKENS.set(DorisLexer.PLAN);
EXPLAIN_TOKENS.set(DorisLexer.PROCESS);

ImmutableMap.Builder<String, Integer> 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();
}

/**
Expand Down Expand Up @@ -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;
}

Expand All @@ -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) {
Expand Down

0 comments on commit e79fb22

Please sign in to comment.