opensearch-project / opensearch-project/sql
[BUG] Inconsistent behavior when query falls back from v2 to v1 SQL engine with unsupported functions and index naming
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?
There's an inconsistency in query handling when the fallback mechanism from v2 to v1 SQL engine is triggered. This creates a confusing user experience where queries might be rejected differently based on multiple unsupported features across both engines.
- V2 engine has stricter index identifier naming restrictions (e.g.,
select * from a.1is not allowed) - V2 engine supports additional functions (e.g.,
from_unixtime) - When V2 engine cannot handle a query, it falls back to V1 engine
- This creates a scenario where:
select * from a.1works in V1 (after V2 rejection)select from_unixtime(t) from a.1falls back to V1 but fails because V1 doesn't supportfrom_unixtime
How can one reproduce the bug?
PUT /a.b
{
"mappings": {
"properties": {
"test_time": {
"type": "long"
}
}
}
}
PUT /a.b/_doc/1
{"test_time": 17424371270}
# Returns formatted date
POST /_plugins/_sql
{
"query": "select from_unixtime(test_time) from a.b"
}
PUT /a.1
{
"mappings": {
"properties": {
"test_time": {
"type": "long"
}
}
}
}
PUT /a.1/_doc/1
{"test_time": 17424371270}
# Error: The following method is not supported in Schema: from_unixtime
POST /_plugins/_sql
{
"query": "select from_unixtime(test_time) from a.1"
}
What is the expected behavior?
A clear and concise description of what you expected to happen.
What is your host/environment?
- OS: [e.g. iOS]
- Version [e.g. 22]
- Plugins
Do you have any screenshots?
If applicable, add screenshots to help explain your problem.
Do you have any additional context?
Add any other context about the problem.
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
No source files or tests are named. Reproduce the two POST /_plugins/_sql cases, then trace how unsupported functions and index identifiers are handled during v2-to-v1 fallback; confirm the intended behavior with maintainers before changing code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- backend-api-design, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100