opensearch-project / opensearch-project/sql
[BUG] Join query doesn't support multi_match function
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?
The JOIN query does not support the multi_match function in the WHERE clause due to table alias missing. This limitation arises due to two primary reasons:
- A validation step requires that the left side of the expression use a table alias.
- The optimizer relies on the alias to determine which table should receive the filtering condition.
How can one reproduce the bug?
@Test
public void multiMatchQuerySingleField() throws IOException {
assertThat(
query(
"SELECT a.firstname",
FROM_ACCOUNTS + " AS a INNER JOIN " + TEST_INDEX_ACCOUNT + " AS b ON a.firstname = b.firstname",
"WHERE MULTI_MATCH('query'='Ayers', 'fields'='firstname')"),
hits(hasValueForFields("Ayers", "firstname")));
}
{
"error": {
"reason": "Invalid SQL query",
"details": "Field ['query' = 'Ayers'] with condition [AND 'query' = 'Ayers' EQ
MULTI_MATCH(com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr@101a1ce6,
com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr@b5dbbdc4)] does not contain an alias",
"type": "SqlParseException"
},
"status": 400
}
What is the expected behavior?
The JOIN query should support the multi_match function in the WHERE clause without problem.
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
Search for the multiMatchQuerySingleField test shown in the issue and run it to reproduce the alias-related SqlParseException. Trace the JOIN WHERE-clause validation and optimization paths involved in that test; done means the query succeeds and returns the expected Ayers firstname hit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100