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
This commit is contained in:
Drew Davis 2025-10-28 12:19:46 -04:00 committed by GitHub
parent 15331acbee
commit d5a38c3e05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---
fix: Fix pattern sample query for sources with multi-column timestamp expressions

View file

@ -13,6 +13,7 @@ import {
TIMESTAMP_COLUMN_ALIAS,
} from '@/hooks/usePatterns';
import useRowWhere from '@/hooks/useRowWhere';
import { getFirstTimestampValueExpression } from '@/source';
import { useZIndex, ZIndexContext } from '@/zIndex';
import styles from '../../styles/LogSidePanel.module.scss';
@ -74,7 +75,7 @@ export default function PatternSidePanel({
],
aliasMap: {
body: bodyValueExpression,
ts: source.timestampValueExpression,
ts: getFirstTimestampValueExpression(source.timestampValueExpression),
},
});

View file

@ -13,6 +13,7 @@ import {
useConfigWithPrimaryAndPartitionKey,
} from '@/components/DBRowTable';
import { useQueriedChartConfig } from '@/hooks/useChartConfig';
import { getFirstTimestampValueExpression } from '@/source';
// We don't want to load pyodide over and over again, use react query to cache the async instance
function usePyodide(options: { enabled: boolean }) {
@ -131,7 +132,7 @@ function usePatterns({
// TODO: User-configurable pattern columns and non-pattern/group by columns
select: [
`${bodyValueExpression} as ${PATTERN_COLUMN_ALIAS}`,
`${config.timestampValueExpression} as ${TIMESTAMP_COLUMN_ALIAS}`,
`${getFirstTimestampValueExpression(config.timestampValueExpression)} as ${TIMESTAMP_COLUMN_ALIAS}`,
...(severityTextExpression
? [`${severityTextExpression} as ${SEVERITY_TEXT_COLUMN_ALIAS}`]
: []),