-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support offset-based timezone #9591
Conversation
✅ Deploy Preview for meta-velox canceled.
|
dc71af9
to
ef9f0c9
Compare
velox/functions/lib/TimeUtils.h
Outdated
return timezone; | ||
} | ||
|
||
// If user doesn't explicitly ask us to adjust the timezone or configured |
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.
/// for multiple line
velox/functions/lib/TimeUtils.h
Outdated
@@ -26,12 +26,30 @@ inline constexpr int64_t kSecondsInDay = 86'400; | |||
inline constexpr int64_t kDaysInWeek = 7; | |||
extern const folly::F14FastMap<std::string, int8_t> kDayOfWeekNames; | |||
|
|||
// Format timezone to make it compatible with date::locate_zone. | |||
// For example, converts "GMT+8" to "Etc/GMT-8". | |||
// Here is the list of IANA timezone names: |
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.
same
velox/expression/CastExpr-inl.h
Outdated
rawTimestamps[row].toGMT(*timeZone); | ||
}); | ||
} | ||
auto* timeZone = |
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.
const auto*
@@ -2385,8 +2405,8 @@ class TestingDictionaryToFewerRowsFunction : public exec::VectorFunction { | |||
exec::EvalCtx& context, | |||
VectorPtr& result) const override { | |||
const auto size = rows.size(); | |||
auto indices = | |||
makeIndices(size, [](auto /*row*/) { return 0; }, context.pool()); | |||
auto indices = makeIndices( |
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.
irrelevant change?
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 change is produced by code format tool. Thanks!
velox/functions/lib/TimeUtils.h
Outdated
if (timezone[3] != '+' && timezone[3] != '-') { | ||
return timezone; | ||
} | ||
std::string prefix = timezone[3] == '+' ? "Etc/GMT-" : "Etc/GMT+"; |
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 format will be more efficient and precise.
if (timezone[3] == '+') {
return "Etc/GMT-" + timezone.substr(4);
} else if (timezone[3] == '-') {
return "Etc/GMT+" + timezone.substr(4);
} else {
return timezone;
}
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.
@jinchengchenghh, yes, thanks for your suggestion! Just updated.
velox/expression/CastExpr.cpp
Outdated
auto sessionTzName = queryConfig.sessionTimezone(); | ||
if (queryConfig.adjustTimestampToTimezone() && !sessionTzName.empty()) { | ||
auto* timeZone = date::locate_zone(sessionTzName); | ||
auto* timeZone = |
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.
const auto*
Hi @pedroerp, could you review this pr? |
1 similar comment
velox/expression/CastExpr-inl.h
Outdated
rawTimestamps[row].toGMT(*timeZone); | ||
}); | ||
} | ||
const auto* timeZone = functions::getTimeZoneFromConfig(queryConfig); |
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.
@PHILO-HE can you rebase? I think I removed this block in the timezone fix I merged yesterday
Another option is to use: https://github.com/facebookincubator/velox/blob/main/velox/type/Timestamp.cpp#L78 it supports conversions of timezone offsets without relying on velox/external/date. It would be nice to align on a single method to support timezone offsets instead of creating a separate one. https://github.com/facebookincubator/velox/blob/main/velox/type/Timestamp.cpp#L28 |
Hi @pedroerp, thanks for your comment! Do you mean we can just use |
Yes :)
velox/external/date is an implementation of std::chrono from C++20, so at the point where all platforms we need to support catch up and provide this as part of the standard library, we can remove it. But outside of that we still need this library to do timezone conversions (just not for offset-based ones). |
I had a question about this. The strings that are now changed to the Prestissimo has a problem with the mappings that I have created an issue for: prestodb/presto#22789 |
This pull request has been automatically marked as stale because it has not had recent activity. If you'd still like this PR merged, please comment on the PR, make sure you've addressed reviewer comments, and rebase on the latest main. Thank you for your contributions! |
Support for this was already added. We should be good to close this one. |
@pedroerp, thanks! Closing this pr. |
The external date lib cannot recognize timezone like "GMT+8",
but it can recognize "Etc/GMT-8". Actually they are equivalent.
So we can do a conversion to support such timezone pattern.
See a discussion in that community: HowardHinnant/date#823.