Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #356 #357

Merged
merged 1 commit into from
Oct 17, 2023
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
14 changes: 10 additions & 4 deletions parser/registry/smart_optimizations/optimization_v3_2.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const { getDuration, dist, Aliased } = require('../common')
const { getDuration, Aliased } = require('../common')
const reg = require('./log_range_agg_reg_v3_2')
const Sql = require('@cloki/clickhouse-sql')
const { DATABASE_NAME, checkVersion } = require('../../../lib/utils')
const streamSelectorReg = require('../stream_selector_operator_registry')
const aggOpReg = require('../high_level_aggregation_registry')
const { clusterName } = require('../../../common')
const logger = require('../../../lib/logger')
const _dist = clusterName ? '_dist' : ''

/**
*
Expand Down Expand Up @@ -46,14 +49,15 @@ module.exports.apply = (token, fromNS, toNS, stepNS) => {
: Sql.Gt('samples.timestamp_ns', fromNS)
let q = (new Sql.Select())
.select(['samples.fingerprint', 'fingerprint'])
.from([`${DATABASE_NAME()}.metrics_15s`, 'samples'])
.from([`${DATABASE_NAME()}.metrics_15s${_dist}`, 'samples'])
.where(tsClause)
q.join(new Aliased(`${DATABASE_NAME()}.time_series${dist}`, 'time_series'), 'left any',
q.join(new Aliased(`${DATABASE_NAME()}.time_series`, 'time_series'), 'left any',
Sql.Eq('samples.fingerprint', new Sql.Raw('time_series.fingerprint')))
q.select([new Sql.Raw('any(JSONExtractKeysAndValues(time_series.labels, \'String\'))'), 'labels'])

q.ctx = {
step: stepNS / 1000000000
step: stepNS / 1000000000,
inline: !!clusterName
}

for (const streamSelectorRule of token.Children('log_stream_selector_rule')) {
Expand All @@ -68,5 +72,7 @@ module.exports.apply = (token, fromNS, toNS, stepNS) => {
q = aggOpReg[aggOp.Child('aggregation_operator_fn').value](aggOp, q)
}

logger.debug(q.toString())

return q
}