-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-39672: [Go] Time to Date32/Date64 conversion issues for non-UTC timezones #39674
Conversation
|
@raulcd this should get cherry-picked into a new RC to fix the failing test |
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.
Test looks good to me. I am not an expert on go so I am not entirely sure why the changes on datatype_fixedwidth.go
are required but as per the test I am ok with the change :)
go/arrow/datatype_fixedwidth.go
Outdated
// the actual value by adjusting the time and converting to UTC | ||
t = t.Add(time.Duration(offset) * time.Second).UTC() | ||
} | ||
t = t.In(time.UTC) |
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.
Time.Unix() claims it is independent of the location, is this strictly needed?
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.
Since in theory if this change were needed, the adjustment above and the adjustment here would be the same?
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.
Good point, you're absolutely right. I'll update and remove those lines
if _, offset := tm.Zone(); offset != 0 { | ||
// normalize the tm | ||
tm = tm.Add(time.Duration(offset) * time.Second).UTC() | ||
} |
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 is effectively taking a timestamp with timezone and turning it into a naive timestamp showing the date in the former timezone (but marked as UTC)?
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.
Yes. Because as you pointed out above, when we call .Unix()
it returns the result not according to the location but we want it to represent the date in the timezone's location, without having a timezone mark associated. This matches the C++ implementation of the casting in acero (which is where I got the idea)
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.
Ok, cool. This just confuses me since I'm used to Java etc. where these are separate types ^_^
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 55afcf0. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them. |
…UTC timezones (apache#39674) A failing unit test in release verification led to discovering an issue with timestamp to date conversions for non-utc timezones. Upon some investigation I was able to determine that it was the conflation of casting conversion behavior (normalize to cast a Timestamp to a Date) vs flat conversion. I've fixed this conflation of concerns and the version of the methods which are exported properly converts non-UTC timezones to dates without affecting Casting behavior. ### Are these changes tested? yes ### Are there any user-facing changes? The methods `Date32FromTime` and `Date64FromTime` will properly handle timezones now. * Closes: apache#39672 Authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
…UTC timezones (apache#39674) A failing unit test in release verification led to discovering an issue with timestamp to date conversions for non-utc timezones. Upon some investigation I was able to determine that it was the conflation of casting conversion behavior (normalize to cast a Timestamp to a Date) vs flat conversion. I've fixed this conflation of concerns and the version of the methods which are exported properly converts non-UTC timezones to dates without affecting Casting behavior. ### Are these changes tested? yes ### Are there any user-facing changes? The methods `Date32FromTime` and `Date64FromTime` will properly handle timezones now. * Closes: apache#39672 Authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
…mezones (#39674) A failing unit test in release verification led to discovering an issue with timestamp to date conversions for non-utc timezones. Upon some investigation I was able to determine that it was the conflation of casting conversion behavior (normalize to cast a Timestamp to a Date) vs flat conversion. I've fixed this conflation of concerns and the version of the methods which are exported properly converts non-UTC timezones to dates without affecting Casting behavior. ### Are these changes tested? yes ### Are there any user-facing changes? The methods `Date32FromTime` and `Date64FromTime` will properly handle timezones now. * Closes: #39672 Authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
…UTC timezones (apache#39674) A failing unit test in release verification led to discovering an issue with timestamp to date conversions for non-utc timezones. Upon some investigation I was able to determine that it was the conflation of casting conversion behavior (normalize to cast a Timestamp to a Date) vs flat conversion. I've fixed this conflation of concerns and the version of the methods which are exported properly converts non-UTC timezones to dates without affecting Casting behavior. ### Are these changes tested? yes ### Are there any user-facing changes? The methods `Date32FromTime` and `Date64FromTime` will properly handle timezones now. * Closes: apache#39672 Authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
…UTC timezones (apache#39674) A failing unit test in release verification led to discovering an issue with timestamp to date conversions for non-utc timezones. Upon some investigation I was able to determine that it was the conflation of casting conversion behavior (normalize to cast a Timestamp to a Date) vs flat conversion. I've fixed this conflation of concerns and the version of the methods which are exported properly converts non-UTC timezones to dates without affecting Casting behavior. ### Are these changes tested? yes ### Are there any user-facing changes? The methods `Date32FromTime` and `Date64FromTime` will properly handle timezones now. * Closes: apache#39672 Authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
A failing unit test in release verification led to discovering an issue with timestamp to date conversions for non-utc timezones.
Upon some investigation I was able to determine that it was the conflation of casting conversion behavior (normalize to cast a Timestamp to a Date) vs flat conversion. I've fixed this conflation of concerns and the version of the methods which are exported properly converts non-UTC timezones to dates without affecting Casting behavior.
Are these changes tested?
yes
Are there any user-facing changes?
The methods
Date32FromTime
andDate64FromTime
will properly handle timezones now.