-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
postgres-source: handle 24:00:00 value for time column #17782
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c9fdbe3
postgres-source: handle 24:00:00 value for time column
subodh1810 a8d4918
Merge branch 'master' into handle-24-hour-time-postgres
subodh1810 9a3d3c7
address review comment
subodh1810 4426b0b
fix test + use LocalTime.MAX
subodh1810 eab2303
bump version
subodh1810 8fd1485
Merge branch 'master' into handle-24-hour-time-postgres
subodh1810 46d3d44
Merge branch 'master' into handle-24-hour-time-postgres
subodh1810 b302266
update alloy db as well
subodh1810 db24e7c
auto-bump connector version [ci skip]
octavia-squidington-iii 7b64eef
auto-bump connector version [ci skip]
octavia-squidington-iii 74222b2
Merge branch 'handle-24-hour-time-postgres' of https://github.com/air…
octavia-squidington-iii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,10 +145,10 @@ public static String convertToTime(final Object time) { | |
return localTime.format(TIME_FORMATTER); | ||
} else if (time instanceof java.time.Duration) { | ||
long value = ((Duration) time).toNanos(); | ||
if (value >= 0 && value <= TimeUnit.DAYS.toNanos(1)) { | ||
if (value >= 0 && value < TimeUnit.DAYS.toNanos(1)) { | ||
return LocalTime.ofNanoOfDay(value).format(TIME_FORMATTER); | ||
} else { | ||
final long updatedValue = 0 > value ? Math.abs(value) : TimeUnit.DAYS.toNanos(1); | ||
final long updatedValue = 0 > value ? Math.abs(value) : 86399999999999L; | ||
LOGGER.debug("Time values must use number of milliseconds greater than 0 and less than 86400000000000 but its {}, converting to {} ", value, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this comment say nanoseconds instead? |
||
updatedValue); | ||
return LocalTime.ofNanoOfDay(updatedValue).format(TIME_FORMATTER); | ||
|
@@ -158,7 +158,13 @@ public static String convertToTime(final Object time) { | |
LOGGER.info("Unknown class for Time data type" + time.getClass()); | ||
loggedUnknownTimeClass = true; | ||
} | ||
return LocalTime.parse(time.toString()).format(TIME_FORMATTER); | ||
|
||
final String valueAsString = time.toString(); | ||
if (valueAsString.startsWith("24")) { | ||
edgao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
LOGGER.debug("Time value {} is above range, converting to 23:59:59", valueAsString); | ||
return LocalTime.parse("23:59:59.999999").format(TIME_FORMATTER); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LocalTime has |
||
} | ||
return LocalTime.parse(valueAsString).format(TIME_FORMATTER); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be more clear, assuming I understood correctly
or maybe just this? I.e. convert negative values to positive, and then cap all values to less than 23:59 - this is slightly different from the current behavior, where
-864000...0000
would be converted to864000...0000
rather than being reduced to 86399999999999)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done