Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NPE thrown for invalid SHOW statement #149

Closed
dai-chen opened this issue Jun 30, 2021 · 0 comments
Closed

[BUG] NPE thrown for invalid SHOW statement #149

dai-chen opened this issue Jun 30, 2021 · 0 comments
Assignees
Labels
bug Something isn't working SQL

Comments

@dai-chen
Copy link
Collaborator

dai-chen commented Jun 30, 2021

Describe the bug
Null pointer error occurs if SHOW TABLES statement doesn't have a filter, such as LIKE xxx.

To Reproduce
Steps to reproduce the behavior:

POST http://localhost:9200/_plugins/_sql
{"query": "SHOW TABLES"}

{
  "error": {
    "reason": "Invalid SQL query",
    "details": "Cannot invoke \"org.antlr.v4.runtime.tree.ParseTree.accept(org.antlr.v4.runtime.tree.ParseTreeVisitor)\" because \"tree\" is null",
    "type": "NullPointerException"
  },
  "status": 400
}

Expected behavior
Syntax error is expected because the SHOW statement is illegal.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS] MacOS
  • Version [e.g. 22] 1.0.0.0-rc1

Additional context
Error stack captured in logs:

[2021-06-30T15:49:51,431][INFO ][o.o.s.l.p.RestSqlAction  ] Incoming request /_plugins/_sql: SHOW TABLES
[2021-06-30T15:49:51,478][ERROR][o.o.s.l.p.RestSqlAction  ] Client side error during query execution
java.lang.NullPointerException: Cannot invoke "org.antlr.v4.runtime.tree.ParseTree.accept(org.antlr.v4.runtime.tree.ParseTreeVisitor)" because "tree" is null
	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18) ~[antlr4-runtime-4.7.1.jar:4.7.1]
	at org.opensearch.sql.sql.parser.AstBuilder.visitAstExpression(AstBuilder.java:214) ~[sql-1.0.0.0-rc1.jar:?]
	at org.opensearch.sql.sql.parser.AstBuilder.visitShowStatement(AstBuilder.java:87) ~[sql-1.0.0.0-rc1.jar:?]
	at org.opensearch.sql.sql.parser.AstBuilder.visitShowStatement(AstBuilder.java:69) ~[sql-1.0.0.0-rc1.jar:?]
	at org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser$ShowStatementContext.accept(OpenSearchSQLParser.java:546) ~[sql-1.0.0.0-rc1.jar:?]
	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46) ~[antlr4-runtime-4.7.1.jar:4.7.1]
	at org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParserBaseVisitor.visitAdminStatement(OpenSearchSQLParserBaseVisitor.java:48) ~[sql-1.0.0.0-rc1.jar:?]
	at org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser$AdminStatementContext.accept(OpenSearchSQLParser.java:485) ~[sql-1.0.0.0-rc1.jar:?]
	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46) ~[antlr4-runtime-4.7.1.jar:4.7.1]
	at org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParserBaseVisitor.visitSqlStatement(OpenSearchSQLParserBaseVisitor.java:27) ~[sql-1.0.0.0-rc1.jar:?]
	at org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser$SqlStatementContext.accept(OpenSearchSQLParser.java:325)
 ...
@dai-chen dai-chen added bug Something isn't working SQL v1.0.0 labels Jun 30, 2021
@dai-chen dai-chen self-assigned this Jun 30, 2021
@dai-chen dai-chen removed the v1.0.0 label Jun 30, 2021
@dai-chen dai-chen closed this as completed Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working SQL
Projects
None yet
Development

No branches or pull requests

1 participant