Skip to content

Commit 27eb666

Browse files
tanjialiangxiaoxmeng
authored andcommitted
[native] Add query trace session properties to native session
1 parent 3236937 commit 27eb666

File tree

2 files changed

+73
-10
lines changed

2 files changed

+73
-10
lines changed

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

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,20 +177,20 @@ SessionProperties::SessionProperties() {
177177
std::to_string(c.rowNumberSpillEnabled()));
178178

179179
addSessionProperty(
180-
kNativeSpillerNumPartitionBits,
180+
kSpillerNumPartitionBits,
181181
"none",
182182
TINYINT(),
183183
false,
184184
QueryConfig::kSpillNumPartitionBits,
185-
std::to_string(c.spillNumPartitionBits())),
185+
std::to_string(c.spillNumPartitionBits()));
186186

187-
addSessionProperty(
188-
kTopNRowNumberSpillEnabled,
189-
"Native Execution only. Enable topN row number spilling on native engine",
190-
BOOLEAN(),
191-
false,
192-
QueryConfig::kTopNRowNumberSpillEnabled,
193-
boolToString(c.topNRowNumberSpillEnabled()));
187+
addSessionProperty(
188+
kTopNRowNumberSpillEnabled,
189+
"Native Execution only. Enable topN row number spilling on native engine",
190+
BOOLEAN(),
191+
false,
192+
QueryConfig::kTopNRowNumberSpillEnabled,
193+
boolToString(c.topNRowNumberSpillEnabled()));
194194

195195
addSessionProperty(
196196
kValidateOutputFromOperators,
@@ -254,6 +254,48 @@ SessionProperties::SessionProperties() {
254254
QueryConfig::kSelectiveNimbleReaderEnabled,
255255
boolToString(c.selectiveNimbleReaderEnabled()));
256256

257+
addSessionProperty(
258+
kQueryTraceEnabled,
259+
"Enables query tracing.",
260+
BOOLEAN(),
261+
false,
262+
QueryConfig::kQueryTraceEnabled,
263+
boolToString(c.queryTraceEnabled()));
264+
265+
addSessionProperty(
266+
kQueryTraceDir,
267+
"Base dir of a query to store tracing data.",
268+
VARCHAR(),
269+
false,
270+
QueryConfig::kQueryTraceDir,
271+
c.queryTraceDir());
272+
273+
addSessionProperty(
274+
kQueryTraceNodeIds,
275+
"A comma-separated list of plan node ids whose input data will be traced."
276+
" Empty string if only want to trace the query metadata.",
277+
VARCHAR(),
278+
false,
279+
QueryConfig::kQueryTraceNodeIds,
280+
c.queryTraceNodeIds());
281+
282+
addSessionProperty(
283+
kQueryTraceMaxBytes,
284+
"The max trace bytes limit. Tracing is disabled if zero.",
285+
BIGINT(),
286+
false,
287+
QueryConfig::kQueryTraceMaxBytes,
288+
std::to_string(c.queryTraceMaxBytes()));
289+
290+
addSessionProperty(
291+
kQueryTraceTaskRegExp,
292+
"The regexp of traced task id. We only enable trace on a task if its id"
293+
" matches.",
294+
BIGINT(),
295+
false,
296+
QueryConfig::kQueryTraceTaskRegExp,
297+
c.queryTraceTaskRegExp());
298+
257299
// If `legacy_timestamp` is true, the coordinator expects timestamp
258300
// conversions without a timezone to be converted to the user's
259301
// session_timezone.

presto-native-execution/presto_cpp/main/SessionProperties.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class SessionProperties {
131131
static constexpr const char* kJoinSpillPartitionBits =
132132
"native_join_spiller_partition_bits";
133133

134-
static constexpr const char* kNativeSpillerNumPartitionBits =
134+
static constexpr const char* kSpillerNumPartitionBits =
135135
"native_spiller_num_partition_bits";
136136

137137
/// Enable topN row number spilling on native engine.
@@ -179,6 +179,27 @@ class SessionProperties {
179179
static constexpr const char* kDriverCpuTimeSliceLimitMs =
180180
"driver_cpu_time_slice_limit_ms";
181181

182+
/// Enables query tracing.
183+
static constexpr const char* kQueryTraceEnabled =
184+
"native_query_trace_enabled";
185+
186+
/// Base dir of a query to store tracing data.
187+
static constexpr const char* kQueryTraceDir = "native_query_trace_dir";
188+
189+
/// A comma-separated list of plan node ids whose input data will be traced.
190+
/// Empty string if only want to trace the query metadata.
191+
static constexpr const char* kQueryTraceNodeIds =
192+
"native_query_trace_node_ids";
193+
194+
/// The max trace bytes limit. Tracing is disabled if zero.
195+
static constexpr const char* kQueryTraceMaxBytes =
196+
"native_query_trace_max_bytes";
197+
198+
/// The regexp of traced task id. We only enable trace on a task if its id
199+
/// matches.
200+
static constexpr const char* kQueryTraceTaskRegExp =
201+
"native_query_trace_task_reg_exp";
202+
182203
SessionProperties();
183204

184205
const std::unordered_map<std::string, std::shared_ptr<SessionProperty>>&

0 commit comments

Comments
 (0)