Skip to content

Conversation

@hohosznta
Copy link

Purpose of this pull request

Add support for TIMESTAMP_TZ on kafka source. Issue #9785

Does this PR introduce any user-facing change?

Yes. The Kafka source connector now supports TIMESTAMP_TZ (timestamp with timezone) data type.
Users can now consume Kafka messages containing timestamp with timezone information (e.g., "2024-01-15T10:30:45Z",
"2024-01-15T10:30:45+09:00") and SeaTunnel will correctly parse them as OffsetDateTime.

How was this patch tested?

Added unit test case in json parsing timestamp_tz in JsonRowDataSerDeSchemaTest.java. (testDeserializationWithTimestampTz)

Check list

@dybyte
Copy link
Contributor

dybyte commented Oct 26, 2025

Hi @hohosznta ,
CI seems to be failing due to formatting (Spotless check).
please check the coding guide.

@dybyte
Copy link
Contributor

dybyte commented Oct 31, 2025

Let's merge the latest changes and try again.

@hohosznta
Copy link
Author

@dybyte thanks, I'll try again.

@hohosznta
Copy link
Author

@dybyte Hi, all CI/CD checks have passed. I’d really appreciate it if you could take a look at my PR.

@dybyte
Copy link
Contributor

dybyte commented Nov 3, 2025

cc @corgy-w @Carl-Zhou-CN

Comment on lines +339 to +362
case TIMESTAMP_TZ:
DateTimeFormatter dateTimeTzFormatter = fieldFormatterMap.get(fieldName);
if (dateTimeTzFormatter == null) {
dateTimeTzFormatter = DateTimeUtils.matchDateTimeFormatter(field);
fieldFormatterMap.put(fieldName, dateTimeTzFormatter);
}
if (dateTimeTzFormatter == null) {
throw CommonError.formatDateTimeError(field, fieldName);
}

TemporalAccessor parsedTimestampTz = dateTimeTzFormatter.parse(field);
LocalTime localTimeTz = parsedTimestampTz.query(TemporalQueries.localTime());
LocalDate localDateTz = parsedTimestampTz.query(TemporalQueries.localDate());
ZoneOffset offset = parsedTimestampTz.query(TemporalQueries.offset());

if (offset == null) {
offset = ZoneId.systemDefault().getRules().getOffset(Instant.now());
}

if (localDateTz == null || localTimeTz == null) {
throw CommonError.formatDateTimeError(field, fieldName);
}

return OffsetDateTime.of(localDateTz, localTimeTz, offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test case for this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants