opensearch-project / opensearch-project/sql-jdbc
[BUG] Unable to run queries with DataGrip
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 28
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
What is the bug?
After setting up the JDBC driver in DataGrip I get inconsistent errors. See reproduction steps for details.
How can one reproduce the bug?
Steps to reproduce the behavior:
- Download the JDBC driver here:
- Open your IDE and open the "Database" section
- Click "+" > "Driver"
- Set the name to "OpenSearch"
- On the "Driver Files" section select the JAR you just downloaded
- In the class dropdown select
org.opensearch.jdbc.Driver - Click "Ok"
- Click "+" > "Data source" > "OpenSearch"
- In the "General" tab:
- Set "Authentication" to "No auth"
- Hostname to the OS cluster address
- In the "Advanced" tab set the following key/value pairs:
auth:AWS_SIGV4region: The region the cluster is on
- Test connection
- Create a test index and put data in it
This is where the behaviors begin:
1234:hadesrodr...s-east-1> select * from hosts_rodrigof_metadata_hosts_2023-04-11
[2023-04-13 11:02:30] java.sql.SQLException
1234:hadesrodr...s-east-1> select * from hosts_rodrigof_metadata_hosts
[2023-04-13 11:08:29] java.sql.SQLException
1234:hadesrodr...s-east-1> select * from "hosts_rodrigof_metadata_hosts"
[2023-04-13 11:08:37] Error executing query
[2023-04-13 11:08:37] HTTP Code: 400. Message: Bad Request. Raw response received: {
[2023-04-13 11:08:37] "error": {
[2023-04-13 11:08:37] "reason": "Error occurred in OpenSearch engine: no such index [\"hosts_rodrigof_metadata_hosts\"]",
[2023-04-13 11:08:37] "details": "org.opensearch.index.IndexNotFoundException: no such index [\"hosts_rodrigof_metadata_hosts\"]\nFor more details, please send request for Json format to see the raw response from OpenSearch engine.",
[2023-04-13 11:08:37] "type": "IndexNotFoundException"
[2023-04-13 11:08:37] },
[2023-04-13 11:08:37] "status": 404
[2023-04-13 11:08:37] }
1234:hadesrodr...s-east-1> select * from "hosts_rodrigof_metadata_hosts_2023-04-11"
[2023-04-13 11:09:05] Error executing query
[2023-04-13 11:09:05] HTTP Code: 400. Message: Bad Request. Raw response received: {
[2023-04-13 11:09:05] "error": {
[2023-04-13 11:09:05] "reason": "Error occurred in OpenSearch engine: no such index [\"hosts_rodrigof_metadata_hosts_2023-04-11\"]",
[2023-04-13 11:09:05] "details": "org.opensearch.index.IndexNotFoundException: no such index [\"hosts_rodrigof_metadata_hosts_2023-04-11\"]\nFor more details, please send request for Json format to see the raw response from OpenSearch engine.",
[2023-04-13 11:09:05] "type": "IndexNotFoundException"
[2023-04-13 11:09:05] },
[2023-04-13 11:09:05] "status": 404
[2023-04-13 11:09:05] }
Where hosts_rodrigof_metadata_hosts_2023-04-11 is an index and hosts_rodrigof_metadata_hosts is an alias. However, using the Elasticsearch plugin, I can successfully run queries via HTTP:
POST /_plugins/_sql/
{
"query": "select count(*) from hosts_rodrigof_metadata_hosts"
}
Returns:
{
"schema": [
{
"name": "count(*)",
"type": "integer"
}
],
"datarows": [
[
12237733
]
],
"total": 1,
"size": 1,
"status": 200
}
Something I have noticed is that the use of * doesn't work, for example:
select * from my_index
Fails with java.sql.SQLException, but:
select col1 from my_index
Does work.
What is the expected behavior?
Queries should run as expected when using the JDBC driver.
What is your host/environment?
- OS: AWS
- Version 2.3
- Plugins: sql
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 DataGrip setup with the JDBC driver and the reported SELECT * and index-alias queries. Compare the driver's requests and errors with the successful OpenSearch SQL HTTP request. Done means the affected queries execute through JDBC and the existing reproduction steps no longer produce SQLException or incorrect index-not-found errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- api, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100