Skip to content

Conversation

@chestnut-c
Copy link
Contributor

@chestnut-c chestnut-c commented Jul 17, 2025

Purpose of this pull request

Postgres supports interval data type for reading and writing. close #9582

Does this PR introduce any user-facing change?

No

How was this patch tested?

for batch task:
The interval data type is not supported before modification
企业微信截图_f3441053-f801-4fbf-9209-fea2a7483c3e

After modification, the interval data type can be read and written normally.

Clipboard_Screenshot_1752762697 Clipboard_Screenshot_1752762722 Clipboard_Screenshot_1752762678

for streaming task:
And it is compatible with cdc scenarios. The Postgres interval type is converted to microseconds (long type) in Debezium such as io.debezium.time.MicroDuration , so if it is an number, it is given in microseconds by default.
Clipboard_Screenshot_1753002878
Clipboard_Screenshot_1753003301

Check list

@github-actions github-actions bot added the e2e label Jul 18, 2025
… in Debezium, so if it is an integer, it is given microseconds by default.
@chestnut-c chestnut-c requested a review from Hisoka-X July 20, 2025 09:22
@chestnut-c chestnut-c changed the title [Fix][Connectors-Jdbc] Postgres supports interval data type for reading and writing. [Fix][Connectors-Jdbc] Postgres supports streaming and batch reading and writing of the interval data type Jul 20, 2025
chestnufang added 2 commits July 21, 2025 10:17
…ium, so if it is a number, it is formatted as a postgres interval value.
@WJX20
Copy link

WJX20 commented Jul 21, 2025

Your way of writing is not quite correct. You directly converted the read-out microsecond numbers into "strings". Debezium's configuration provides an 'interval.handling.mode' attribute. Seatunnel should retain this attribute. When reading the Debezium configuration, the user can choose whether to select 'string' or 'number'.
interval

@WJX20
Copy link

WJX20 commented Jul 21, 2025

Moreover, your approach only covers the "day" type. The "interval" type should also include "month" and "year".
The processing method for the interval data type is that the default value is 365.25 days for a year, and 365.25/12 = 30.4375 days for a month.

@chestnut-c
Copy link
Contributor Author

chestnut-c commented Jul 21, 2025

Debezium

@WJX20 Yes, I am dealing with the default number type when the 'interval.handling.mode parameter is not used. Since Debezium does not retain the format when reading, in order to make the data calculation more accurate, it is only formatted to the day. Even if it is calculated to the year and month, it is still impossible to guarantee the same format. As long as the interval data is consistent, the format does not have to be the same. other ,If you need the same format, you can try using the interval.handling.mode parameter to get the interval data in string format containing year, month, and day.

@chestnut-c
Copy link
Contributor Author

chestnut-c commented Jul 21, 2025

interval.handling.mode

Clipboard_Screenshot_1753091513

The default type currently processed is io.debezium.time.MicroDuration
The default type is to keep the accuracy as much as possible and convert it to day format by default.u can use this way debezium={"interval.handling.mode":"string"} to support setting the interval.handling.mode parameter to keep the original format io.debezium.time.Interval
Clipboard_Screenshot_1753091623

@WJX20
Copy link

WJX20 commented Jul 21, 2025

got off work

@chestnut-c
Copy link
Contributor Author

chestnut-c commented Jul 21, 2025

got off work

@WJX20 now you can use this configuration parameter interval.handling.mode,I think it is supported, the test is OK, the format has been preserved, u can use this way debezium={"interval.handling.mode":"string"} to support setting the interval.handling.mode parameter
Clipboard_Screenshot_1753093008
企业微信截图_49f439c6-e018-4a30-aa67-c9ed7dcfbc85

企业微信截图_bfbccb7a-545c-4a47-aa49-2dc666de5083

Hisoka-X
Hisoka-X previously approved these changes Jul 21, 2025
Copy link
Member

@Hisoka-X Hisoka-X left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @chestnut-c

@WJX20
Copy link

WJX20 commented Jul 22, 2025

ok,Let me test it. The naming of 'inetObject' is not standard. This is of the 'INET' data type.
intervalObject

@chestnut-c
Copy link
Contributor Author

ok,Let me test it. The naming of 'inetObject' is not standard. This is of the 'INET' data type. intervalObject

ok i will fix it next time

@corgy-w
Copy link
Contributor

corgy-w commented Jul 22, 2025

@chestnut-c I changed the variable name and it's OK. If I wait a moment and merge it

Copy link
Contributor

@corgy-w corgy-w left a comment

Choose a reason for hiding this comment

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

wait ci

@chestnut-c
Copy link
Contributor Author

@chestnut-c I changed the variable name and it's OK. If I wait a moment and merge it

ok thx @corgy-w

@Hisoka-X Hisoka-X merged commit 58ab917 into apache:dev Jul 22, 2025
6 checks passed
dybyte pushed a commit to dybyte/seatunnel that referenced this pull request Jul 23, 2025
…and writing of the `interval` data type (apache#9590)

Co-authored-by: chestnufang <[email protected]>
Co-authored-by: corgy-w <[email protected]>
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.

[Bug] [seatunnel-connectors-v2] Not support the pg "interval" data type

4 participants