mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
fix: Ensure percentile aggregations on histograms dont create invalid SQL queries due to improperly escaped aliases. (#1021)
Closes #1020 Closes HDX-2063 <img width="1855" height="897" alt="image" src="https://github.com/user-attachments/assets/5f7f0505-934c-4da0-8e46-f07aa5035455" />
This commit is contained in:
parent
6c134035c4
commit
61c79a16a4
3 changed files with 15 additions and 8 deletions
7
.changeset/little-parents-rescue.md
Normal file
7
.changeset/little-parents-rescue.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
"@hyperdx/common-utils": patch
|
||||
"@hyperdx/api": patch
|
||||
"@hyperdx/app": patch
|
||||
---
|
||||
|
||||
fix: Ensure percentile aggregations on histograms don't create invalid SQL queries due to improperly escaped aliases.
|
||||
|
|
@ -82,10 +82,10 @@ exports[`renderChartConfig histogram metric queries should generate a query with
|
|||
WHEN upper_bound = inf THEN point[upper_idx - 1].2
|
||||
WHEN lower_bound = inf THEN point[1].2
|
||||
ELSE lower_bound + (upper_bound - lower_bound) * ((rank - lower_count) / (upper_count - lower_count))
|
||||
END AS Value
|
||||
END AS \\"Value\\"
|
||||
FROM points
|
||||
WHERE length(point) > 1 AND total > 0
|
||||
) SELECT \`__hdx_time_bucket\`, group, Value FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
|
||||
) SELECT \`__hdx_time_bucket\`, group, \\"Value\\" FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
|
||||
`;
|
||||
|
||||
exports[`renderChartConfig histogram metric queries should generate a query without grouping but time bucketing 1`] = `
|
||||
|
|
@ -166,10 +166,10 @@ exports[`renderChartConfig histogram metric queries should generate a query with
|
|||
WHEN upper_bound = inf THEN point[upper_idx - 1].2
|
||||
WHEN lower_bound = inf THEN point[1].2
|
||||
ELSE lower_bound + (upper_bound - lower_bound) * ((rank - lower_count) / (upper_count - lower_count))
|
||||
END AS Value
|
||||
END AS \\"Value\\"
|
||||
FROM points
|
||||
WHERE length(point) > 1 AND total > 0
|
||||
) SELECT \`__hdx_time_bucket\`, Value FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
|
||||
) SELECT \`__hdx_time_bucket\`, \\"Value\\" FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
|
||||
`;
|
||||
|
||||
exports[`renderChartConfig histogram metric queries should generate a query without grouping or time bucketing 1`] = `
|
||||
|
|
@ -250,10 +250,10 @@ exports[`renderChartConfig histogram metric queries should generate a query with
|
|||
WHEN upper_bound = inf THEN point[upper_idx - 1].2
|
||||
WHEN lower_bound = inf THEN point[1].2
|
||||
ELSE lower_bound + (upper_bound - lower_bound) * ((rank - lower_count) / (upper_count - lower_count))
|
||||
END AS Value
|
||||
END AS \\"Value\\"
|
||||
FROM points
|
||||
WHERE length(point) > 1 AND total > 0
|
||||
) SELECT \`__hdx_time_bucket\`, Value FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
|
||||
) SELECT \`__hdx_time_bucket\`, \\"Value\\" FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
|
||||
`;
|
||||
|
||||
exports[`renderChartConfig should generate sql for a single gauge metric 1`] = `
|
||||
|
|
|
|||
|
|
@ -1250,13 +1250,13 @@ async function translateMetricChartConfig(
|
|||
WHEN upper_bound = inf THEN point[upper_idx - 1].2
|
||||
WHEN lower_bound = inf THEN point[1].2
|
||||
ELSE lower_bound + (upper_bound - lower_bound) * ((rank - lower_count) / (upper_count - lower_count))
|
||||
END AS ${valueAlias}
|
||||
END AS "${valueAlias}"
|
||||
FROM points
|
||||
WHERE length(point) > 1 AND total > 0
|
||||
`,
|
||||
},
|
||||
],
|
||||
select: `\`__hdx_time_bucket\`${groupBy ? ', group' : ''}, ${valueAlias}`,
|
||||
select: `\`__hdx_time_bucket\`${groupBy ? ', group' : ''}, "${valueAlias}"`,
|
||||
from: {
|
||||
databaseName: '',
|
||||
tableName: 'metrics',
|
||||
|
|
|
|||
Loading…
Reference in a new issue