Skip to content
Open
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
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
24 changes: 22 additions & 2 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 @@ -192,7 +192,27 @@ describe('processRowToWhereClause', () => {
const row = { dynamic_field: '{\\"took\\":7, not 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, not 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
7 changes: 2 additions & 5 deletions packages/app/src/hooks/useRowWhere.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,14 @@ 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),
return SqlString.format(`toString(??)='?'`, [
valueExpr,
SqlString.raw(
value[0] === '"' && value[value.length - 1] === '"'
? value.slice(1, -1)
Expand Down