Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions presto-native-execution/presto_cpp/main/QueryContextManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void updateFromSystemConfigs(
}
}

std::unordered_map<std::string, std::string> toConfigs(
std::unordered_map<std::string, std::string> toVeloxConfigs(
const protocol::SessionRepresentation& session) {
// Use base velox query config as the starting point and add Presto session
// properties on top of it.
Expand Down Expand Up @@ -117,6 +117,27 @@ toConnectorConfigs(const protocol::SessionRepresentation& session) {

return connectorConfigs;
}

void updateVeloxConfigs(
std::unordered_map<std::string, std::string>& configStrings) {
// If `legacy_timestamp` is true, the coordinator expects timestamp
// conversions without a timezone to be converted to the user's
// session_timezone.
auto it = configStrings.find("legacy_timestamp");
// `legacy_timestamp` default value is true in the coordinator.
if ((it == configStrings.end()) || (folly::to<bool>(it->second))) {
configStrings.emplace(
core::QueryConfig::kAdjustTimestampToTimezone, "true");
}
// TODO: remove this once cpu driver slicing config is turned on by default in
// Velox.
it = configStrings.find(core::QueryConfig::kDriverCpuTimeSliceLimitMs);
if (it == configStrings.end()) {
// Set it to 1 second to be aligned with Presto Java.
configStrings.emplace(
core::QueryConfig::kDriverCpuTimeSliceLimitMs, "1000");
}
}
} // namespace

QueryContextManager::QueryContextManager(
Expand All @@ -129,7 +150,7 @@ QueryContextManager::findOrCreateQueryCtx(
const protocol::TaskId& taskId,
const protocol::SessionRepresentation& session) {
return findOrCreateQueryCtx(
taskId, toConfigs(session), toConnectorConfigs(session));
taskId, toVeloxConfigs(session), toConnectorConfigs(session));
}

std::shared_ptr<core::QueryCtx> QueryContextManager::findOrCreateQueryCtx(
Expand All @@ -146,16 +167,7 @@ std::shared_ptr<core::QueryCtx> QueryContextManager::findOrCreateQueryCtx(
return queryCtx;
}

// If `legacy_timestamp` is true, the coordinator expects timestamp
// conversions without a timezone to be converted to the user's
// session_timezone.
auto it = configStrings.find("legacy_timestamp");

// `legacy_timestamp` default value is true in the coordinator.
if ((it == configStrings.end()) || (folly::to<bool>(it->second))) {
configStrings.emplace(
core::QueryConfig::kAdjustTimestampToTimezone, "true");
}
updateVeloxConfigs(configStrings);

std::unordered_map<std::string, std::shared_ptr<Config>> connectorConfigs;
for (auto& entry : connectorConfigStrings) {
Expand Down