nzw921rx opened a new issue, #13361:
URL: https://github.com/apache/seatunnel/issues/13361
### What happened
On SeaTunnel 3.1.0, a one-row `FakeSource → Calcite → Console` job finishes
with `SELECT * FROM t` and prints `2025-02-03T09:10:11.123456` for the `ts`
column. Changing only the query to `SELECT ts FROM t` makes the job fail with
`ClassCastException`. The failure happens inside the transform, before the sink
receives the row.
Calling the released `CalciteSQLEngine` directly also reproduces the
exception for both `SELECT ts FROM t` and `SELECT ts + INTERVAL '1' SECOND AS
shifted FROM t`. Both `.123` and `.123456` inputs fail for `TIMESTAMP`. The
same two queries also fail with an `OffsetDateTime` input (`TIMESTAMP_TZ`) at
`.123456Z`.
### Environment
Apache SeaTunnel 3.1.0, Zeta local mode, Eclipse Temurin 11.0.32.1.
### Minimal job
Save this as `calcite-timestamp.conf`.
```hocon
env {
job.mode = "BATCH"
parallelism = 1
}
source {
FakeSource {
plugin_output = "t"
row.num = 1
schema {
table = "t"
fields { id = "int", ts = "timestamp", tod = "time" }
}
rows = [{ fields = [7, "2025-02-03T09:10:11.123456", "09:10:11.123456"],
kind = INSERT }]
}
}
transform {
Calcite {
plugin_input = "t"
plugin_output = "projected"
sql = "SELECT ts FROM t"
}
}
sink { Console { plugin_input = "projected" } }
```
```sh
bin/seatunnel.sh --master local --config calcite-timestamp.conf
```
To reproduce the successful control, change only `sql` to `"SELECT * FROM
t"`.
### Error
```text
Caused by: java.lang.ClassCastException: class java.sql.Timestamp cannot be
cast to class java.lang.Long
at Baz$1$1.current(Unknown Source)
at
org.apache.seatunnel.shade.org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.next(Linq4j.java:674)
```
The input converter supplies a `java.sql.Timestamp` for `LocalDateTime` and
`OffsetDateTime`. The generated code for the failing projections expects a
`Long`.
[CalciteValueConverter](https://github.com/apache/seatunnel/blob/3.1.0/seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/calcite/type/CalciteValueConverter.java#L45-L60)
### Expected behavior and regression coverage
- Selecting `ts` on its own should return the same timestamp and fractional
seconds as selecting it in `*`.
- Adding one whole second to `2025-02-03T09:10:11.123456` should yield
`2025-02-03T09:10:12.123456`. Checking the returned value would also catch a
fix that silently truncates to milliseconds.
- For the MySQL CDC use case, please cover a snapshot row and a binlog
update through `MySQL-CDC → Calcite → JDBC` with six-digit source and sink
columns. Check the stored values of both MySQL `DATETIME(6)` and
`TIMESTAMP(6)`. This is proposed end-to-end coverage. The reproductions above
use FakeSource and the released transform directly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]