Skip to content

Commit d53d8e4

Browse files
committed
[native] remove native prefix for native connector session property
1 parent 348e991 commit d53d8e4

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

presto-native-execution/presto_cpp/main/QueryContextManager.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,16 @@ toConnectorConfigs(const protocol::SessionRepresentation& session) {
6464
std::unordered_map<std::string, std::unordered_map<std::string, std::string>>
6565
connectorConfigs;
6666
for (const auto& entry : session.catalogProperties) {
67+
std::unordered_map<std::string, std::string> connectorConfig;
68+
// remove native prefix from native connector session property names
69+
for (const auto& sessionProperty : entry.second) {
70+
auto veloxConfig = (sessionProperty.first.rfind("native_", 0) == 0)
71+
? sessionProperty.first.substr(7)
72+
: sessionProperty.first;
73+
connectorConfig.emplace(veloxConfig, sessionProperty.second);
74+
}
6775
connectorConfigs.insert(
68-
{entry.first,
69-
std::unordered_map<std::string, std::string>(
70-
entry.second.begin(), entry.second.end())});
76+
{entry.first, connectorConfig});
7177
}
7278

7379
return connectorConfigs;

presto-native-execution/presto_cpp/main/tests/QueryContextManagerTest.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,25 @@ TEST_F(QueryContextManagerTest, nativeSessionProperties) {
7777
EXPECT_EQ(queryCtx->queryConfig().exprMaxCompiledRegexes(), 54321);
7878
}
7979

80+
TEST_F(QueryContextManagerTest, nativeConnectorSessionProperties) {
81+
protocol::TaskId taskId = "scan.0.0.1.0";
82+
protocol::SessionRepresentation session;
83+
std::map<std::string, std::string> hiveSessions{
84+
{"native_stats_based_filter_reorder_disabled", "true"},
85+
{"orc_max_merge_distance", "512kB"}};
86+
session.catalogProperties.emplace("hive", hiveSessions);
87+
auto queryCtx = taskManager_->getQueryContextManager()->findOrCreateQueryCtx(
88+
taskId, session);
89+
EXPECT_EQ(
90+
queryCtx->connectorSessionProperties().at("hive")->get<std::string>(
91+
"orc_max_merge_distance"),
92+
"512kB");
93+
EXPECT_EQ(
94+
queryCtx->connectorSessionProperties().at("hive")->get<std::string>(
95+
"stats_based_filter_reorder_disabled"),
96+
"true");
97+
}
98+
8099
TEST_F(QueryContextManagerTest, defaultSessionProperties) {
81100
const std::unordered_map<std::string, std::string> values;
82101
auto defaultQC = std::make_shared<velox::core::QueryConfig>(values);

0 commit comments

Comments
 (0)