This is an automated email from the ASF dual-hosted git repository.
hyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new 4d1c3e5 [CALCITE-3474] NullPointerException in SqlSimpleParser
toke.s.equals() (Xiucheng Qu)
4d1c3e5 is described below
commit 4d1c3e54fc4172c7ff00db3326823c42f237cf04
Author: quxiucheng <quxiucheng>
AuthorDate: Mon Nov 4 16:59:01 2019 +0800
[CALCITE-3474] NullPointerException in SqlSimpleParser toke.s.equals()
(Xiucheng Qu)
Close #1558
---
.../java/org/apache/calcite/sql/advise/SqlSimpleParser.java | 10 +++++-----
.../test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java | 4 ++++
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git
a/core/src/main/java/org/apache/calcite/sql/advise/SqlSimpleParser.java
b/core/src/main/java/org/apache/calcite/sql/advise/SqlSimpleParser.java
index a71a9ad..2e29d6d 100644
--- a/core/src/main/java/org/apache/calcite/sql/advise/SqlSimpleParser.java
+++ b/core/src/main/java/org/apache/calcite/sql/advise/SqlSimpleParser.java
@@ -196,7 +196,7 @@ public class SqlSimpleParser {
if (iter.hasNext()) {
token = iter.next();
if ((token.type == TokenType.ID)
- && token.s.equalsIgnoreCase("ALL")) {
+ && "ALL".equalsIgnoreCase(token.s)) {
outList.add(token);
} else {
iter.previous();
@@ -521,7 +521,7 @@ public class SqlSimpleParser {
for (Token token : tokenList) {
switch (token.type) {
case ID:
- if (token.s.equals(hintToken)) {
+ if (hintToken.equals(token.s)) {
foundInClause = clause;
}
break;
@@ -652,7 +652,7 @@ public class SqlSimpleParser {
}
break;
case ID:
- if (token.s.equals(hintToken)) {
+ if (hintToken.equals(token.s)) {
found = true;
}
}
@@ -735,7 +735,7 @@ public class SqlSimpleParser {
itemStart = i + 1;
break;
case ID:
- if (token.s.equals(hintToken)) {
+ if (hintToken.equals(token.s)) {
found = true;
}
}
@@ -815,7 +815,7 @@ public class SqlSimpleParser {
for (Token token : tokenList) {
switch (token.type) {
case ID:
- if (token.s.equals(hintToken)) {
+ if (hintToken.equals(token.s)) {
return true;
}
break;
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
b/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
index 74ccadb..ace3ebf 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
@@ -961,6 +961,10 @@ public class SqlAdvisorTest extends SqlValidatorTestCase {
sql = "select t.x from (select 1 as x, 2 as y from sales.^) as t";
assertComplete(sql, getSalesTables());
+
+ // CALCITE-3474:SqlSimpleParser toke.s equals NullPointerException
+ sql = "select ^ from (select * from sales.emp) as t";
+ assertComplete(sql, getSelectKeywords(), tTable, EMP_COLUMNS,
EXPR_KEYWORDS);
}
@Test public void testSubQueryInWhere() {