Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e04d083
fix: delimited column identifier for dynamic fields
tombokombo Aug 31, 2025
5d615c8
add changeset
tombokombo Sep 4, 2025
5133faa
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 4, 2025
adcd081
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 15, 2025
7ab8f68
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 16, 2025
a6daf74
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 18, 2025
0eff426
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 19, 2025
be63881
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 22, 2025
5ad60c3
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 24, 2025
e0b1093
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 27, 2025
1acc85f
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 27, 2025
7c3d7eb
escape single quote for dynamic
tombokombo Sep 29, 2025
7403fb9
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 29, 2025
4afeca7
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 29, 2025
80a1a97
Merge branch 'main' into fix/delimited_identifier
tombokombo Sep 30, 2025
5f31e45
Merge branch 'main' into fix/delimited_identifier
tombokombo Oct 1, 2025
de5898d
Merge branch 'main' into fix/delimited_identifier
tombokombo Oct 2, 2025
57a4965
Merge branch 'main' into fix/delimited_identifier
tombokombo Oct 3, 2025
18f8daa
Merge branch 'main' into fix/delimited_identifier
tombokombo Oct 7, 2025
3afc688
Merge branch 'main' into fix/delimited_identifier
tombokombo Oct 7, 2025
83dc590
fix test
tombokombo Oct 7, 2025
82233e4
Merge branch 'main' into fix/delimited_identifier
tombokombo Oct 8, 2025
b57fc16
Merge branch 'main' into fix/delimited_identifier
tombokombo Oct 9, 2025
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
5 changes: 5 additions & 0 deletions .changeset/clean-waves-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---

fix delimited column identifier for dynamic fields
26 changes: 23 additions & 3 deletions packages/app/src/hooks/__tests__/useRowWhere.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('processRowToWhereClause', () => {
const row = { dynamic_field: '"quoted_value"' };
const result = processRowToWhereClause(row, columnMap);

expect(result).toBe("toString(dynamic_field)='quoted_value'");
expect(result).toBe("toString(`dynamic_field`)='quoted_value'");
});

it('should handle Dynamic columns with escaped values', () => {
Expand All @@ -189,10 +189,30 @@ describe('processRowToWhereClause', () => {
],
]);

const row = { dynamic_field: '{\\"took\\":7, not a valid json' };
const row = { dynamic_field: '{\\"took\\":7, this ins\'t a valid json' };
const result = processRowToWhereClause(row, columnMap);
expect(result).toBe(
'toString(dynamic_field)=\'{\\"took\\":7, not a valid json\'',
"toString(`dynamic_field`)='{\\\"took\\\":7, this ins't a valid json'",
);
});

it('should handle Dynamic columns with delimited identifier', () => {
const columnMap = new Map([
[
'dynamic_field.nested.needs\\toBeEscaped',
{
name: 'dynamic_field.nested\\ToBeEscaped',
type: 'Dynamic',
valueExpr: 'dynamic_field.nested.needs\\ToBeEscaped',
jsType: JSDataType.Dynamic,
},
],
]);

const row = { 'dynamic_field.nested.needs\\toBeEscaped': 'some string' };
const result = processRowToWhereClause(row, columnMap);
expect(result).toBe(
`toString(\`dynamic_field\`.\`nested\`.\`needs\\ToBeEscaped\`)='some string'`,
);
});

Expand Down
14 changes: 6 additions & 8 deletions packages/app/src/hooks/useRowWhere.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,19 @@ export function processRowToWhereClause(
if (value === 'null') {
return SqlString.format(`isNull(??)`, [column]);
}
if (value.length > 1000 || column.length > 1000) {
console.warn('Search value/object key too large.');
}
// TODO: update when JSON type have new version
// will not work for array/object dyanmic data

// escaped strings needs raw, becuase sqlString will add another layer of escaping
// data other than array/object will alwayas return with dobule quote(because of CH)
// remove dobule qoute to search correctly
return SqlString.format(`toString(?)='?'`, [
SqlString.raw(valueExpr),
// remove double quotes if present and escape single quotes
return SqlString.format(`toString(??)='?'`, [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this could break the alias expression. We should check if tests pass after this PR (#1231)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so we are waiting till PR (#1231) becomes merged ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wrn14897 let's try tests :)

Copy link
Contributor Author

@tombokombo tombokombo Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wrn14897 my local build passed tests and this patch is still needed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tombokombo can you resolve the conflicts?

valueExpr,
SqlString.raw(
value[0] === '"' && value[value.length - 1] === '"'
(value[0] === '"' && value[value.length - 1] === '"'
? value.slice(1, -1)
: value,
: value
).replace(/'/g, "\\'"),
),
]);
default:
Expand Down