apache / apache/linkis

[Bug] JDBC engine query time in milliseconds lost

Open
#5,307 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
3.4k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

### Search before asking

- [x] I searched the `https://github.com/apache/linkis/issues` and found no similar issues.



### Linkis Component

linkis-engineconn-plugins/jdbc

### Steps to reproduce

1. Use JDBC engine to query a table with datetime/timestamp columns containing milliseconds
2. Execute SQL like: `SELECT timestamp_column FROM test_table`
3. Observe the query result

### Expected behavior

Datetime values should display complete with milliseconds, e.g., `1970-01-21 00:35:35.506`

### Actual behavior

Milliseconds are lost, displaying only `1970-01-21 00:35:35`

### Your environment

- Linkis version used: 1.1.2
- Environment name and version:
- cdh-5.14.2
- hdp-3.1.5
- hive-2.1.1
- spark-3.2.1
- scala-2.12.2
- jdk 1.8.0_121


### Root Cause Analysis

1. In `JDBCEngineConnExecutor.scala`, the code uses `resultSet.getString()` for all types including datetime, which may lose milliseconds depending on JDBC driver implementation
2. In `DataType.scala`, the `TimestampType` handling uses `stripSuffix(".0")` which removes all milliseconds, including non-zero ones

### Solution

1. Modify result set processing to directly call `toString()` on `java.sql.Timestamp` objects
2. Remove `stripSuffix(".0")` from TimestampType conversion to preserve all milliseconds

### Anything else

_No response_

### Are you willing to submit a PR?

- [x] Yes I am willing to submit a PR!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.