Skip to content

Commit 60ef80b

Browse files
committedOct 21, 2024
fix IN -> global in
1 parent 4dcd757 commit 60ef80b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
 

‎traceql/clickhouse_transpiler/traces_data.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { standardBuilder } = require('./shared')
44
* @type {ProcessFn}
55
*/
66
const processFn = (sel, ctx) => {
7+
const _in = ctx.isCluster ? 'global in' : 'in'
78
const table = !ctx.isCluster ? ctx.tracesTable : ctx.tracesDistTable
89
const withMain = new Sql.With('index_grouped', sel)
910
const withTraceIds = new Sql.With('trace_ids', (new Sql.Select())
@@ -17,18 +18,18 @@ const processFn = (sel, ctx) => {
1718
.with(withMain, withTraceIds, withTraceIdsSpanIds)
1819
.select(
1920
[new Sql.Raw('lower(hex(traces.trace_id))'), 'trace_id'],
20-
[new Sql.Raw(`arrayMap(x -> lower(hex(x)), groupArrayIf(traces.span_id, (traces.trace_id, traces.span_id) IN ${new Sql.WithReference(withTraceIdsSpanIds)}))`), 'span_id'],
21-
[new Sql.Raw(`groupArrayIf(traces.duration_ns, (traces.trace_id, traces.span_id) IN ${new Sql.WithReference(withTraceIdsSpanIds)})`), 'duration'],
22-
[new Sql.Raw(`groupArrayIf(traces.timestamp_ns, (traces.trace_id, traces.span_id) IN ${new Sql.WithReference(withTraceIdsSpanIds)})`), 'timestamp_ns'],
21+
[new Sql.Raw(`arrayMap(x -> lower(hex(x)), groupArrayIf(traces.span_id, (traces.trace_id, traces.span_id) ${_in} ${new Sql.WithReference(withTraceIdsSpanIds)}))`), 'span_id'],
22+
[new Sql.Raw(`groupArrayIf(traces.duration_ns, (traces.trace_id, traces.span_id) ${_in} ${new Sql.WithReference(withTraceIdsSpanIds)})`), 'duration'],
23+
[new Sql.Raw(`groupArrayIf(traces.timestamp_ns, (traces.trace_id, traces.span_id) ${_in} ${new Sql.WithReference(withTraceIdsSpanIds)})`), 'timestamp_ns'],
2324
[new Sql.Raw('min(traces.timestamp_ns)'), 'start_time_unix_nano'],
2425
[new Sql.Raw(
2526
'toFloat64(max(traces.timestamp_ns + traces.duration_ns) - min(traces.timestamp_ns)) / 1000000'
2627
), 'duration_ms'],
2728
[new Sql.Raw('argMin(traces.name, traces.timestamp_ns)', 'root_service_name'), 'root_service_name'],
28-
[new Sql.Raw(`groupArrayIf(base64Encode(traces.payload), (traces.trace_id, traces.span_id) IN ${new Sql.WithReference(withTraceIdsSpanIds)})`), 'payload'],
29-
[new Sql.Raw(`groupArrayIf(traces.payload_type, (traces.trace_id, traces.span_id) IN ${new Sql.WithReference(withTraceIdsSpanIds)})`), 'payload_type']
29+
[new Sql.Raw(`groupArrayIf(base64Encode(traces.payload), (traces.trace_id, traces.span_id) ${_in} ${new Sql.WithReference(withTraceIdsSpanIds)})`), 'payload'],
30+
[new Sql.Raw(`groupArrayIf(traces.payload_type, (traces.trace_id, traces.span_id) ${_in} ${new Sql.WithReference(withTraceIdsSpanIds)})`), 'payload_type']
3031
).from([table, 'traces']).where(Sql.And(
31-
new Sql.In(new Sql.Raw('traces.trace_id'), 'in', new Sql.WithReference(withTraceIds))
32+
new Sql.In(new Sql.Raw('traces.trace_id'), _in, new Sql.WithReference(withTraceIds))
3233
)).groupBy('traces.trace_id')
3334
.orderBy(['start_time_unix_nano', 'desc'])
3435
}

0 commit comments

Comments
 (0)