opensearch-project / opensearch-project/sql-jdbc

[BUG] `getColumnTypeName` for timestamp depends on cursor on/off

Open
#90 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
28
Forks
39
PR merge metrics
No merged PRs in 30d

Description

What is the bug?

getColumnTypeName for timestamp depends whether cursor feature is active

How can one reproduce the bug?

Steps to reproduce the behavior:

  1. Create an index and a doc:
curl -s -H 'Content-Type: application/json' -XPUT "http://localhost:9200/date_type_index?pretty" -d '{"mappings": {"properties": {"release_date": {"type": "date" }}}}'
curl -s -H 'Content-Type: application/json' -XPOST "http://localhost:9200/date_type_index/_doc?pretty" -d '{"release_date": "2022-11-16"}'
  1. Query it without cursor:
Connection conn = driver.connect(connStr, properties);
Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery("select * from date_type_index");
ResultSetMetaData rsmd = rs.getMetaData();
String typeName = rsmd.getColumnTypeName("release_date");
  1. typeName is TIMESTAMP
  2. Query it with cursor:
Connection conn = driver.connect(connStr, properties);
Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(5);
ResultSet rs = stmt.executeQuery("select * from date_type_index");
ResultSetMetaData rsmd = rs.getMetaData();
String typeName = rsmd.getColumnTypeName("release_date");
  1. typeName is DATE

What is the expected behavior?

It should be always timestamp since SQL plugin reports this type:

{
  "schema": [
    {
      "name": "release_date",
      "type": "timestamp"
    }
  ],
  "datarows": [
    [
      "2022-11-16 00:00:00"
    ]
  ],
  "total": 1,
  "size": 1,
  "status": 200
}

What is your host/environment?

  • OpenSearch 2.5
  • JDBC 5e8d914d @ main

Do you have any screenshots?

N/A

Do you have any additional context?

Thanks @akuzin1 for reporting that

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the JDBC ResultSetMetaData.getColumnTypeName entry point and reproduce the issue with the reported cursor-off and cursor-on statements. Compare the metadata for release_date in both cases; done when both paths report TIMESTAMP consistently with the SQL plugin schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.