opensearch-project / opensearch-project/sql-jdbc

[BUG] JDBC doesn't return second fraction part for timestamp

Open
#16 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?

Reason: manual parsing of timestamp values
https://github.com/opensearch-project/sql/blob/c923e80cd654ee8136c74180bf0bd6231044ff71/sql-jdbc/src/main/java/org/opensearch/jdbc/types/TimestampType.java#L63-L96

How can one reproduce the bug?

select timestamp("1970-01-01 12:00:00.501");
JDBC output:

image

SQL plugin output:
fetched rows / total rows = 73/73
+-------------------------+--------------------------------+
| val                     | key                            |
|-------------------------+--------------------------------|
| null                    | null                           |
| 1899-01-01 20:00:00     | 001: 1899-01-01 12:00:00       |
| 1899-12-31 20:00:00     | 002: 1899-12-31 12:00:00       |
| 1940-02-29 20:00:00     | 003: 1940-02-29 12:00:00       |
| 1970-01-01 08:00:00     | 004: 1970-01-01 00:00:00-epoch |
| 1970-01-01 08:00:01     | 005: 1970-01-01 00:00:01       |
| 1970-01-01 09:00:00     | 006: 1970-01-01 01:00:00       |
| 1970-01-01 09:59:00     | 007: 1970-01-01 01:59:00       |
| 1970-01-01 09:59:59     | 008: 1970-01-01 01:59:59       |
| 1970-01-01 10:00:00     | 009: 1970-01-01 02:00:00       |
| 1970-01-01 10:00:01     | 010: 1970-01-01 02:00:01       |
| 1970-01-01 10:30:00.1   | 011: 1970-01-01 02:30:00.1     |
| 1970-01-01 11:00:00.2   | 012: 1970-01-01 03:00:00.2     |
| 1970-01-01 12:00:00.3   | 013: 1970-01-01 04:00:00.3     |
| 1970-01-01 13:00:00.4   | 014: 1970-01-01 05:00:00.4     |
| 1970-01-01 14:00:00.5   | 015: 1970-01-01 06:00:00.5     |
| 1970-01-01 15:00:00.6   | 016: 1970-01-01 07:00:00.6     |
| 1970-01-01 16:00:00.7   | 017: 1970-01-01 08:00:00.7     |
| 1970-01-01 17:00:00.8   | 018: 1970-01-01 09:00:00.8     |
| 1970-01-01 18:00:00.9   | 019: 1970-01-01 10:00:00.9     |
| 1970-01-01 19:59:00.499 | 020: 1970-01-01 11:59:00.499   |
| 1970-01-01 19:59:59.5   | 021: 1970-01-01 11:59:59.500   |
| 1970-01-01 20:00:00.501 | 022: 1970-01-01 12:00:00.501   |

What is the expected behavior?

Use API for parsing, e.g. Timestamp.valueOf method:

java.sql.Timestamp.valueOf("1970-01-01 12:00:00.501") = 1970-01-01 12:00:00.501

What is your host/environment?

2.x @ e2bf2544

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 with sql-jdbc/src/main/java/org/opensearch/jdbc/types/TimestampType.java, especially lines 63-96, and reproduce the issue with select timestamp("1970-01-01 12:00:00.501"). Compare the JDBC result with java.sql.Timestamp.valueOf and verify that the returned timestamp preserves the fractional seconds shown by the SQL plugin output.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.