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 with json respone formatter on "SELECT 1" #3188

Open
noCharger opened this issue Dec 4, 2024 · 0 comments
Open

[BUG] NPE with json respone formatter on "SELECT 1" #3188

noCharger opened this issue Dec 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@noCharger
Copy link
Collaborator

noCharger commented Dec 4, 2024

What is the bug?
NPE with json respone formatter on "SELECT 1"

It works fine with default format

curl -X POST "localhost:9200/_plugins/_sql" -H "Content-Type: application/json" -d'
{
        "query": "select 1"
}'
{
  "schema": [
    {
      "name": "1",
      "type": "integer"
    }
  ],
  "datarows": [
    [
      1
    ]
  ],
  "total": 1,
  "size": 1,
  "status": 200
}%    

How can one reproduce the bug?


 curl -X POST "localhost:9200/_plugins/_sql?format=json&pretty=true" -H "Content-Type: application/json" -d'
{
	"query": "select 1"
}'

{
  "error": {
    "reason": "Invalid SQL query",
    "details": "Cannot invoke \"com.alibaba.druid.sql.ast.statement.SQLTableSource.getAlias()\" because the return value of \"com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.getFrom()\" is null",
    "type": "NullPointerException"
  },
  "status": 400
}

What is the expected behavior?
Return valid json response

Additional info

Stacktrace

java.lang.NullPointerException: Cannot invoke "com.alibaba.druid.sql.ast.statement.SQLTableSource.getAlias()" because the return value of "com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.getFrom()" is null
	at org.opensearch.sql.legacy.parser.SqlParser.parseSelect(SqlParser.java:81) ~[legacy-3.0.0.0-SNAPSHOT.jar:?]
	at org.opensearch.sql.legacy.parser.SqlParser.parseSelect(SqlParser.java:68) ~[legacy-3.0.0.0-SNAPSHOT.jar:?]
	at org.opensearch.sql.legacy.query.OpenSearchActionFactory.create(OpenSearchActionFactory.java:120) ~[legacy-3.0.0.0-SNAPSHOT.jar:?]
	at org.opensearch.sql.legacy.plugin.SearchDao.explain(SearchDao.java:48) ~[legacy-3.0.0.0-SNAPSHOT.jar:?]
	at org.opensearch.sql.legacy.plugin.RestSqlAction.explainRequest(RestSqlAction.java:243) [legacy-3.0.0.0-SNAPSHOT.jar:?]
	at org.opensearch.sql.legacy.plugin.RestSqlAction.lambda$prepareRequest$1(RestSqlAction.java:172) [legacy-3.0.0.0-SNAPSHOT.jar:?]
	at org.opensearch.sql.legacy.plugin.RestSQLQueryAction.lambda$prepareRequest$0(RestSQLQueryAction.java:92) [legacy-3.0.0.0-SNAPSHOT.jar:?]

@noCharger noCharger added bug Something isn't working untriaged labels Dec 4, 2024
@Swiddis Swiddis removed the untriaged label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants