opensearch-project / opensearch-project/sql-jdbc
[BUG] JDBC doesn't return second fraction part for timestamp
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?
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:

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
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 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