Skip to content
Draft
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions .changeset/range-bound-escapes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@hyperdx/common-utils': patch
'@hyperdx/api': patch
'@hyperdx/app': patch
---

fix: decode escaped characters in Lucene range bounds

A range bound with an escaped colon, such as
`Timestamp:[2024-01-01T10\:00\:00 TO *]`, sent the internal placeholder to
ClickHouse (`'2024-01-01T10HDX_COLON00HDX_COLON00'`) and the query failed. Range
bounds are now decoded the same way as other search terms.
8 changes: 8 additions & 0 deletions packages/common-utils/src/__tests__/queryParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,14 @@ describe('CustomSchemaSQLSerializerV2 - range bounds', () => {
lucene: 'Timestamp:{2024-01-01 TO 2024-06-01}',
sql: "((Timestamp > '2024-01-01' AND Timestamp < '2024-06-01'))",
},
{
lucene: 'Timestamp:[2024-01-01T10\\:00\\:00 TO *]',
sql: "((Timestamp >= '2024-01-01T10:00:00'))",
},
{
lucene: 'Host:[localhost:3000 TO localhost:3999]',
sql: "((Host BETWEEN 'localhost:3000' AND 'localhost:3999'))",
},
{
lucene: 'LogAttributes.duration_ms:{100 TO 500}',
sql: "((`LogAttributes`['duration_ms'] > 100 AND `LogAttributes`['duration_ms'] < 500 AND indexHint(mapContains(`LogAttributes`, 'duration_ms'))))",
Expand Down
4 changes: 2 additions & 2 deletions packages/common-utils/src/queryParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2083,8 +2083,8 @@ async function nodeTerm(
const rangedTerm = node;
return serializer.range(
field,
rangedTerm.term_min,
rangedTerm.term_max,
decodeSpecialTokens(rangedTerm.term_min),
decodeSpecialTokens(rangedTerm.term_max),
Comment thread
breken-ai marked this conversation as resolved.
Resolved
isNegatedField,
context,
rangedTerm.inclusive,
Expand Down
Loading