You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "MukjepScarlet (via GitHub)" <gi...@apache.org> on 2026/02/03 10:29:40 UTC
[PR] [Fix][Connectors-V2] SQLServer type `datetimeoffset` be converted to incorrect Java type `LocalDateTime` [seatunnel]
MukjepScarlet opened a new pull request, #10441:
URL: https://github.com/apache/seatunnel/pull/10441
<!--
Thank you for contributing to SeaTunnel! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
## Contribution Checklist
- Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
- Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
- Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
-->
### Purpose of this pull request
<!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
Fix type issue for SQLServer
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
If no, write 'No'.
If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
-->
Yes, `datetimeoffset` is now `java.time.OffsetDateTime` in result row.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If you are adding E2E test cases, maybe refer to https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/resources/mysqlcdc_to_mysql.conf, here is a good example.
-->
TODO
### Check list
* [ ] If any new Jar binary package adding in your PR, please add License Notice according
[New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
* [ ] If necessary, please update `incompatible-changes.md` to describe the incompatibility caused by this PR.
* [ ] If you are contributing the connector code, please check that the following files are updated:
1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connectors-V2] SQLServer type `datetimeoffset` be converted to incorrect Java type `LocalDateTime` [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #10441:
URL: https://github.com/apache/seatunnel/pull/10441#issuecomment-4318619263
I noticed that https://github.com/apache/seatunnel/pull/10724 solved this problem, you can choose to close this PR
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connectors-V2] SQLServer type `datetimeoffset` be converted to incorrect Java type `LocalDateTime` [seatunnel]
Posted by "MukjepScarlet (via GitHub)" <gi...@apache.org>.
MukjepScarlet commented on PR #10441:
URL: https://github.com/apache/seatunnel/pull/10441#issuecomment-4318624648
It's fine to close this but I have a question about #10724, when will it be ready (merged)?
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connectors-V2] SQLServer type `datetimeoffset` be converted to incorrect Java type `LocalDateTime` [seatunnel]
Posted by "MukjepScarlet (via GitHub)" <gi...@apache.org>.
MukjepScarlet closed pull request #10441: [Fix][Connectors-V2] SQLServer type `datetimeoffset` be converted to incorrect Java type `LocalDateTime`
URL: https://github.com/apache/seatunnel/pull/10441
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connectors-V2] SQLServer type `datetimeoffset` be converted to incorrect Java type `LocalDateTime` [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10441:
URL: https://github.com/apache/seatunnel/pull/10441#issuecomment-4198905567
Thanks for the update, and welcome again.
I re-checked the latest diff locally. The original `TIMESTAMP_WITH_TIMEZONE` fallback issue that I called out earlier is fixed now, so the main `datetimeoffset -> OffsetDateTime` direction is much closer.
I found one new blocking regression in the latest patch though:
- in `SqlServerTypeConverter.java`, `POWER_2_31` was changed to `1 << 31`
- in Java this is evaluated as an `int` shift first, so it becomes `-2147483648`, not `2147483648`
- that value is then reused in the SQL Server MAX-length branches (`VARCHAR(MAX)`, `NVARCHAR(MAX)`, `TEXT`, `XML`, `VARBINARY(MAX)`, `IMAGE`), so their inferred `columnLength` can become negative / corrupted
Could you please change those constants to `1L << 30` and `1L << 31` (or just keep the previous long-safe form), and add one regression assertion that checks the literal expected value instead of reusing the same constant from the production class?
One more note if you want to keep the sink-side `datetimeoffset` change in this PR: the new `SqlserverJdbcRowConverter.toExternal(SeaTunnelRowType, ...)` overload is not part of the `JdbcRowConverter` interface, so the normal batch executors still go through `AbstractJdbcRowConverter.toExternal(TableSchema, ...)`. If sink-side binding is in scope here, that path still needs to be wired through the real interface method.
The read-side direction is definitely much closer now. Happy to take another look after the MAX-length constant is fixed.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connectors-V2] SQLServer type `datetimeoffset` be converted to incorrect Java type `LocalDateTime` [seatunnel]
Posted by "nielifeng (via GitHub)" <gi...@apache.org>.
nielifeng commented on PR #10441:
URL: https://github.com/apache/seatunnel/pull/10441#issuecomment-3844687769
Thanks for the fix! The type mapping change to `OFFSET_DATE_TIME_TYPE` looks correct for preserving timezone information.
However, I noticed a potential compatibility issue with the CDC connector, which shares this type converter.
1. **CDC Converter Support**:
The `SeaTunnelRowDebeziumDeserializationConverters` class currently lacks support for `SqlType.TIMESTAMP_TZ` (which corresponds to `OFFSET_DATE_TIME_TYPE`).
Please verify if this change will cause `UnsupportedOperationException` in CDC tasks. You likely need to add a case for `TIMESTAMP_TZ` in `SeaTunnelRowDebeziumDeserializationConverters#createConverter`.
2. **TemporalConversions**:
If you update the Debezium converter, you might also need to add a `toOffsetDateTime` utility method in `TemporalConversions.java` to handle the conversion from Debezium's internal representation to `OffsetDateTime`.
It would be great if you could ensure that both JDBC and CDC connectors work correctly with this new type mapping.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connectors-V2] SQLServer type `datetimeoffset` be converted to incorrect Java type `LocalDateTime` [seatunnel]
Posted by "MukjepScarlet (via GitHub)" <gi...@apache.org>.
MukjepScarlet commented on PR #10441:
URL: https://github.com/apache/seatunnel/pull/10441#issuecomment-4198942224
> One more note if you want to keep the sink-side datetimeoffset change in this PR: the new SqlserverJdbcRowConverter.toExternal(SeaTunnelRowType, ...) overload is not part of the JdbcRowConverter interface, so the normal batch executors still go through AbstractJdbcRowConverter.toExternal(TableSchema, ...). If sink-side binding is in scope here, that path still needs to be wired through the real interface method.
I want to know the correct (or recommended) way to handle this. Thank you.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connectors-V2] SQLServer type `datetimeoffset` be converted to incorrect Java type `LocalDateTime` [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10441:
URL: https://github.com/apache/seatunnel/pull/10441#issuecomment-4199877813
Thanks for the quick follow-up, and welcome again.
I re-checked the latest head (`f622bb2bf7`) locally. The two blocking issues I called out earlier are fixed now:
- `JdbcColumnConverter` has the `TIMESTAMP` / `TIMESTAMP_WITH_TIMEZONE` split restored, so the fallback path no longer regresses plain `TIMESTAMP`
- `POWER_2_31` is now back to a long-safe shift (`1L << 31`), so the MAX-length branches are no longer corrupted
On your sink-side question: the recommended hook point is the interface-based runtime path, not the new `SeaTunnelRowType` helper overload.
The normal JDBC sink executors call:
- `SimpleBatchStatementExecutor.addToBatch()` -> `JdbcRowConverter.toExternal(TableSchema, @Nullable TableSchema, ...)`
- `InsertOrUpdateBatchStatementExecutor.addToBatch()` -> the same interface path
So if you want a SQL Server-specific sink override later, I would recommend overriding `toExternal(TableSchema, @Nullable TableSchema, ...)` directly, similar to the Postgres / Kingbase converters, rather than expanding the `SeaTunnelRowType` helper. In the current code, the generic `AbstractJdbcRowConverter` path already handles `TIMESTAMP_TZ`, so I do not see a remaining blocking issue on the read-side fix in this PR.
One small non-blocking follow-up if you want to polish the regression coverage later: at least one MAX-length assertion would be stronger if it checked the literal expected value instead of reusing the production constant.
From my side, the original blocking issue is cleared now. Nice progress on this.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connectors-V2] SQLServer type `datetimeoffset` be converted to incorrect Java type `LocalDateTime` [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10441:
URL: https://github.com/apache/seatunnel/pull/10441#issuecomment-4198252393
Thanks for working on this, and welcome to contributing here.
I re-checked the latest diff locally, and the main `datetimeoffset -> OffsetDateTime` direction looks right, but I found one blocking regression on the catalog fallback path.
In `JdbcColumnConverter.convert(...)`, `case TIMESTAMP:` now falls through into `case TIMESTAMP_WITH_TIMEZONE:` because the `break` disappeared (`JdbcColumnConverter.java:224-228`). That means a normal JDBC `TIMESTAMP` column is now also mapped to `OFFSET_DATE_TIME_TYPE`, not just `TIMESTAMP_WITH_TIMEZONE`.
This path is still reachable from the normal catalog/schema inference fallback in `CatalogUtils.getTableSchema()` / `getCatalogTable(ResultSetMetaData)` (`CatalogUtils.java:229-239`, `266-274`), so the regression is not just dead deprecated code.
I think this PR is very close: if you restore the `break` here and add a regression test that covers the fallback `JdbcColumnConverter` path, I’m happy to take another look.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org