opensearch-project / opensearch-project/sql
[BUG] unsupported operator: if when using sql API
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 176
- Forks
- 229
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 43
Description
What is the bug?
Opensearch version 2.8.0
we are migrating from elasticsearch to opensearch and planning to use nested sql queries to replace runtime field which were supported in elasticsearch sql API
after following documentation from https://opensearch.org/docs/2.0/search-plugins/sql/sql-ppl-api/#query-api
when I try to run sql query using if operator I get following exception
{
"error": {
"reason": "There was internal problem at backend",
"details": "unsupported operator: if",
"type": "UnsupportedOperationException"
},
"status": 503
}
same query works in query workbench. if I use nested query only group by fields are returned.
How can one reproduce the bug?
Steps to reproduce the behavior:
- call _sql API to run query in jdbc format
- post sql query
- go to query workbench and verify query works
steps to replicate in dev console (queries works workbench)
POST _bulk
{ "index" : { "_index" : "test_bulk1", "_id" : "1" } }
{ "a": "a", "id": 1 }
GET test_bulk1/_search
POST /_plugins/_sql?format=jdbc
{
"query": "SELECT IF(id=1, 1, 0 ) as id FROM test_bulk1 group by a",
"fetch_size" : 10
}
POST /_plugins/_sql?format=jdbc
{
"query": "SELECT *FROM (SELECT IF(id=1, 1, 0 ) as id FROM test_bulk1 group by a)as tmp",
"fetch_size" : 10
}
What is the expected behavior?
output from query workbench and SQL needs to be consistent
What is your host/environment?
- OS: Centos 7
- Opensearch Version 2.8.0
- Plugins
Do you have any screenshots?
N/A
Do you have any additional context?
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the JDBC-formatted requests to /_plugins/_sql with the provided bulk data and IF queries, then compare them with the query workbench behavior. Trace the SQL API handling of nested queries and the IF operator; done means equivalent results are returned consistently instead of an unsupported-operator error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- api, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100