Skip to content

Commit d5a38c3

Browse files
authored
fix: Fix pattern sample query for sources with multi-column timestamp expressions (#1304)
Fixes HDX-2621 # Summary This PR fixes a query error when opening a sample log line in the patterns table from a source with multiple timestamp columns. To fix the issue, we simply use the first of the timestamp columns. This is consistent with several other places in the app where we use just the first timestamp column - multiple timestamp columns is not fully supported. ## Testing To reproduce the issue, set the Timestamp Column in source settings for the logs source to `TimestampTime, toStartOfMinute(TimestampTime)`. Then attempt to open a pattern sample: https://github.com/user-attachments/assets/2464f97e-1423-437c-88f0-b45486feffcc With these changes, the issue is fixed: https://github.com/user-attachments/assets/54d8f0f2-532c-4eb4-a676-ab6a606ecac5
1 parent 15331ac commit d5a38c3

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

.changeset/blue-hairs-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
fix: Fix pattern sample query for sources with multi-column timestamp expressions

packages/app/src/components/PatternSidePanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
TIMESTAMP_COLUMN_ALIAS,
1414
} from '@/hooks/usePatterns';
1515
import useRowWhere from '@/hooks/useRowWhere';
16+
import { getFirstTimestampValueExpression } from '@/source';
1617
import { useZIndex, ZIndexContext } from '@/zIndex';
1718

1819
import styles from '../../styles/LogSidePanel.module.scss';
@@ -74,7 +75,7 @@ export default function PatternSidePanel({
7475
],
7576
aliasMap: {
7677
body: bodyValueExpression,
77-
ts: source.timestampValueExpression,
78+
ts: getFirstTimestampValueExpression(source.timestampValueExpression),
7879
},
7980
});
8081

packages/app/src/hooks/usePatterns.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
useConfigWithPrimaryAndPartitionKey,
1414
} from '@/components/DBRowTable';
1515
import { useQueriedChartConfig } from '@/hooks/useChartConfig';
16+
import { getFirstTimestampValueExpression } from '@/source';
1617

1718
// We don't want to load pyodide over and over again, use react query to cache the async instance
1819
function usePyodide(options: { enabled: boolean }) {
@@ -131,7 +132,7 @@ function usePatterns({
131132
// TODO: User-configurable pattern columns and non-pattern/group by columns
132133
select: [
133134
`${bodyValueExpression} as ${PATTERN_COLUMN_ALIAS}`,
134-
`${config.timestampValueExpression} as ${TIMESTAMP_COLUMN_ALIAS}`,
135+
`${getFirstTimestampValueExpression(config.timestampValueExpression)} as ${TIMESTAMP_COLUMN_ALIAS}`,
135136
...(severityTextExpression
136137
? [`${severityTextExpression} as ${SEVERITY_TEXT_COLUMN_ALIAS}`]
137138
: []),

0 commit comments

Comments
 (0)