Skip to content

Commit

Permalink
Fix empty time zone
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Dec 25, 2024
1 parent 9e5d869 commit 35a6511
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
24 changes: 14 additions & 10 deletions velox/functions/sparksql/specialforms/SparkCastHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,19 @@
namespace facebook::velox::functions::sparksql {

SparkCastHooks::SparkCastHooks(const velox::core::QueryConfig& config)
: config_(config) {}
: config_(config) {
timestampToStringOptions_ = {
.precision = TimestampToStringOptions::Precision::kMicroseconds,
.leadingPositiveSign = true,
.skipTrailingZeros = true,
.zeroPaddingYear = true,
.dateTimeSeparator = ' ',
};
const auto sessionTzName = config.sessionTimezone();
if (!sessionTzName.empty()) {
timestampToStringOptions_.timeZone = tz::locateZone(sessionTzName);
}
}

Expected<Timestamp> SparkCastHooks::castStringToTimestamp(
const StringView& view) const {
Expand Down Expand Up @@ -80,15 +92,7 @@ StringView SparkCastHooks::removeWhiteSpaces(const StringView& view) const {

const TimestampToStringOptions& SparkCastHooks::timestampToStringOptions()
const {
static TimestampToStringOptions options = {
.precision = TimestampToStringOptions::Precision::kMicroseconds,
.leadingPositiveSign = true,
.skipTrailingZeros = true,
.zeroPaddingYear = true,
.dateTimeSeparator = ' ',
.timeZone = tz::locateZone(config_.sessionTimezone()),
};
return options;
return timestampToStringOptions_;
}

exec::PolicyType SparkCastHooks::getPolicy() const {
Expand Down
1 change: 1 addition & 0 deletions velox/functions/sparksql/specialforms/SparkCastHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ class SparkCastHooks : public exec::CastHooks {

private:
const core::QueryConfig& config_;
TimestampToStringOptions& timestampToStringOptions_;
};
} // namespace facebook::velox::functions::sparksql

0 comments on commit 35a6511

Please sign in to comment.