Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(data-quality): describe each run result in the terms of its check type (#104006)

Thiago Salvatore5493c8aea9e4
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 8047b7c4682a..641421239754 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2481,9 +2481,9 @@ snapshots:
data-catalog-metric-tests--unsupported-with-checks--light:
hash: v1.k794b7964.64e9162a5dd7bc47a1667f13d8c77b4d1f00c6e15c70169ab4d4ffc588dd2112.j2HS8sjcKIg0QXaZ9PLel28BVD4vayBEBRzrHVO-dlI
data-quality-check-runs-table--every-check-type--dark:
- hash: v1.k794b7964.adbcb016bd78e4ca2cd9e744794f254c580567d44ec75f2e27cb89d2ae135df0.imF2IHlEi-KBkQ6jP17iC-nrPXQzL2_TWen4HdP8oOI
+ hash: v1.k794b7964.8cdbb71c619659feb900c816afd412ec8fe0a99c8b44fc956275282ef56b3c3e.tMGIu_lh3Uf5WvR8QXUP3iSTRKFPFS2u9Y6Wl8Ouay4
data-quality-check-runs-table--every-check-type--light:
- hash: v1.k794b7964.e2f7204c2e97806e7325909eb60601d1064614b434ce2309f00e35e13264f438.hZz-kbvnlkChSvEg1xkm0Na0kFBD46FKshLYwcV5vcs
+ hash: v1.k794b7964.e90e41b601b4690332e483ff2a1d4df0cb8456d1c92f92a97ef25cfe5f87e182.8HRaicZOtyvYQWwDDffAr_NGSMuQOfySkIb4xgd9K5Q
data-warehouse-destinationlist--both-selected--dark:
hash: v1.k794b7964.5da0169833ea8b87e6d903cb4fc0f4d629a1b1db09149c5fb7c450ef312641a0.MH4OyaTjM18a4cpxtpCHPVm1QWWajZL5cz4NlzbJag0
data-warehouse-destinationlist--both-selected--light:
diff --git a/products/data_quality/frontend/CheckRunsTable.test.tsx b/products/data_quality/frontend/CheckRunsTable.test.tsx
index 68e81799eb16..3e369ebd47e9 100644
--- a/products/data_quality/frontend/CheckRunsTable.test.tsx
+++ b/products/data_quality/frontend/CheckRunsTable.test.tsx
@@ -36,11 +36,10 @@ function metricRun(overrides: Partial<DataQualityCheckRunApi>): DataQualityCheck
describe('CheckRunsTable', () => {
afterEach(cleanup)
- it('shows metric failures and execution errors without an observed metric value', () => {
+ it('describes each run in the terms of its check type', () => {
initKeaTests()
render(
<CheckRunsTable
- subjectType="metric"
runs={[
PASSING_METRIC_RUN,
metricRun({
@@ -64,16 +63,15 @@ describe('CheckRunsTable', () => {
expect(screen.getByText('passed')).toBeInTheDocument()
expect(screen.getByText('failed')).toBeInTheDocument()
expect(screen.getByText('errored')).toBeInTheDocument()
- expect(screen.getByText('7')).toBeInTheDocument()
+ expect(screen.getByText('7 rows returned')).toBeInTheDocument()
expect(screen.getByText('Unknown column signups')).toBeInTheDocument()
- expect(screen.queryByText('Observed value')).not.toBeInTheDocument()
+ expect(screen.queryByText('Failed rows')).not.toBeInTheDocument()
})
it('shows a freshness run as how old its newest row is', () => {
initKeaTests()
render(
<CheckRunsTable
- subjectType="table"
runs={[
metricRun({
subject_type: 'table',
diff --git a/products/data_quality/frontend/CheckRunsTable.tsx b/products/data_quality/frontend/CheckRunsTable.tsx
index 800db698c8cc..9a8b455219f2 100644
--- a/products/data_quality/frontend/CheckRunsTable.tsx
+++ b/products/data_quality/frontend/CheckRunsTable.tsx
@@ -3,10 +3,8 @@ import { LemonTable, LemonTag, Tooltip } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
import { LemonTableColumn } from 'lib/lemon-ui/LemonTable'
import { humanFriendlyDuration } from 'lib/utils/durations'
-import { humanFriendlyNumber } from 'lib/utils/numbers'
-import type { DataQualitySubjectType } from './checksApi'
-import { CHECK_STATUS_TAG_TYPES, byStatusAttention, checkRunDisplayName, observedValueCell } from './checksConstants'
+import { CHECK_STATUS_TAG_TYPES, byStatusAttention, checkRunDisplayName, runResultCell } from './checksConstants'
import type { DataQualityCheckRunApi } from './generated/api.schemas'
type CheckRunColumn = LemonTableColumn<DataQualityCheckRunApi, keyof DataQualityCheckRunApi | undefined>
@@ -35,10 +33,10 @@ const OUTCOME_COLUMNS: CheckRunColumn[] = [
run.duration_ms === null ? '-' : humanFriendlyDuration(run.duration_ms / 1000, { maxUnits: 2 }),
},
{
- title: 'Observed value',
+ title: 'Result',
key: 'observed_value',
render: (_, run) => {
- const { label, tooltip } = observedValueCell(run)
+ const { label, tooltip } = runResultCell(run)
return tooltip ? (
<Tooltip title={tooltip}>
<span>{label}</span>
@@ -48,11 +46,6 @@ const OUTCOME_COLUMNS: CheckRunColumn[] = [
)
},
},
- {
- title: 'Failed rows',
- key: 'failed_row_count',
- render: (_, run) => (run.failed_row_count === null ? '-' : humanFriendlyNumber(run.failed_row_count)),
- },
{
title: 'Error',
key: 'error',
@@ -71,12 +64,9 @@ interface CheckRunsTableProps {
runs: DataQualityCheckRunApi[]
loading?: boolean
showCheck?: boolean
- subjectType?: DataQualitySubjectType
}
-export function CheckRunsTable({ runs, loading, showCheck, subjectType }: CheckRunsTableProps): JSX.Element {
- const outcomeColumns =
- subjectType === 'metric' ? OUTCOME_COLUMNS.filter((column) => column.key !== 'observed_value') : OUTCOME_COLUMNS
+export function CheckRunsTable({ runs, loading, showCheck }: CheckRunsTableProps): JSX.Element {
return (
<LemonTable
size="small"
@@ -84,7 +74,7 @@ export function CheckRunsTable({ runs, loading, showCheck, subjectType }: CheckR
loading={loading}
nouns={['run', 'runs']}
emptyState="No runs yet"
- columns={showCheck ? [CHECK_COLUMN, ...outcomeColumns] : outcomeColumns}
+ columns={showCheck ? [CHECK_COLUMN, ...OUTCOME_COLUMNS] : OUTCOME_COLUMNS}
/>
)
}
diff --git a/products/data_quality/frontend/ChecksTable.tsx b/products/data_quality/frontend/ChecksTable.tsx
index c7d25ce536aa..f66ffe3eefdd 100644
--- a/products/data_quality/frontend/ChecksTable.tsx
+++ b/products/data_quality/frontend/ChecksTable.tsx
@@ -48,7 +48,6 @@ export function ChecksTable({ columns, outputSchema, ...props }: ChecksTableProp
<div className="flex flex-col gap-2 py-2">
{check.description && <p className="mb-0 text-secondary">{check.description}</p>}
<CheckRunsTable
- subjectType={props.subjectType}
runs={checkRunsByCheckId[check.id] ?? []}
loading={pendingCheckActions.loadingRuns[check.id]}
/>
diff --git a/products/data_quality/frontend/SuiteRunsHistory.tsx b/products/data_quality/frontend/SuiteRunsHistory.tsx
index 29071aa34766..d9ce34b700a0 100644
--- a/products/data_quality/frontend/SuiteRunsHistory.tsx
+++ b/products/data_quality/frontend/SuiteRunsHistory.tsx
@@ -50,7 +50,6 @@ export function SuiteRunsHistory(props: DataQualityChecksLogicProps): JSX.Elemen
onRowExpand: (suiteRun) => loadSuiteRunCheckRuns(suiteRun.id),
expandedRowRender: (suiteRun) => (
<CheckRunsTable
- subjectType={props.subjectType}
runs={suiteRunCheckRunsBySuiteRunId[suiteRun.id] ?? []}
loading={pendingCheckActions.loadingSuiteRunRuns[suiteRun.id]}
showCheck
diff --git a/products/data_quality/frontend/checksConstants.test.ts b/products/data_quality/frontend/checksConstants.test.ts
index ee8f734a3d39..3ab2f43593c5 100644
--- a/products/data_quality/frontend/checksConstants.test.ts
+++ b/products/data_quality/frontend/checksConstants.test.ts
@@ -1,6 +1,6 @@
import { dayjs } from 'lib/dayjs'
-import { byStatusAttention, checkRunDisplayName, failingForLabel, observedValueCell } from './checksConstants'
+import { byStatusAttention, checkRunDisplayName, failingForLabel, runResultCell } from './checksConstants'
import { CheckTypeEnumApi } from './generated/api.schemas'
describe('checksConstants', () => {
@@ -85,24 +85,24 @@ describe('checksConstants', () => {
CheckTypeEnumApi.RowCount,
1493355,
{ min: 1000000, max: 2000000 },
- '1,493,355 rows',
- '1,493,355 rows. The limit is between 1,000,000 and 2,000,000\u00a0rows.',
+ '1,493,355\u00a0rows',
+ '1,493,355\u00a0rows. The limit is between 1,000,000 and 2,000,000\u00a0rows.',
],
[
'a row count run with one bound names only that one',
CheckTypeEnumApi.RowCount,
12,
{ max: 10 },
- '12 rows',
- '12 rows. The limit is at most 10\u00a0rows.',
+ '12\u00a0rows',
+ '12\u00a0rows. The limit is at most 10\u00a0rows.',
],
[
'a row count run with a bound of one reads in the singular',
CheckTypeEnumApi.RowCount,
0,
{ min: 1 },
- '0 rows',
- '0 rows. The limit is at least 1\u00a0row.',
+ '0\u00a0rows',
+ '0\u00a0rows. The limit is at least 1\u00a0row.',
],
[
'a freshness run whose newest row is ahead of the clock says so',
@@ -112,11 +112,27 @@ describe('checksConstants', () => {
'1h in the future',
'Newest row is 3,600 seconds in the future. The limit is 1d\u00a012h.',
],
- ['a not null run stays a plain number', CheckTypeEnumApi.NotNull, 7, null, '7', null],
+ ['a not null run counts null rows', CheckTypeEnumApi.NotNull, 7, null, '7\u00a0null rows', null],
+ [
+ 'a unique run counts duplicate values, singular at one',
+ CheckTypeEnumApi.Unique,
+ 1,
+ null,
+ '1\u00a0duplicate value',
+ null,
+ ],
+ [
+ 'a custom SQL run counts the rows its query returned',
+ CheckTypeEnumApi.CustomSql,
+ 0,
+ null,
+ '0\u00a0rows returned',
+ null,
+ ],
['a run with nothing observed shows a dash', CheckTypeEnumApi.Freshness, null, null, '-', null],
])('%s', (_case, checkType, observedValue, checkConfig, label, tooltip) => {
expect(
- observedValueCell({ check_type: checkType, observed_value: observedValue, check_config: checkConfig })
+ runResultCell({ check_type: checkType, observed_value: observedValue, check_config: checkConfig })
).toEqual({ label, tooltip })
})
})
diff --git a/products/data_quality/frontend/checksConstants.ts b/products/data_quality/frontend/checksConstants.ts
index c71b6474ec18..5d8f0b477cac 100644
--- a/products/data_quality/frontend/checksConstants.ts
+++ b/products/data_quality/frontend/checksConstants.ts
@@ -130,14 +130,22 @@ export function checkRunDisplayName(
const SECONDS_PER_MINUTE = 60
const DURATION_UNITS = 2
-export interface ObservedValueCell {
+const FAILING_ROW_NOUNS: Partial<Record<CheckTypeEnumApi, [string, string]>> = {
+ [CheckTypeEnumApi.NotNull]: ['null row', 'null rows'],
+ [CheckTypeEnumApi.Unique]: ['duplicate value', 'duplicate values'],
+ [CheckTypeEnumApi.AcceptedValues]: ['row outside the set', 'rows outside the set'],
+ [CheckTypeEnumApi.Relationships]: ['row with no match', 'rows with no match'],
+ [CheckTypeEnumApi.CustomSql]: ['row returned', 'rows returned'],
+}
+
+export interface RunResultCell {
label: string
tooltip: string | null
}
-export function observedValueCell(
+export function runResultCell(
run: Pick<DataQualityCheckRunApi, 'check_type' | 'observed_value' | 'check_config'>
-): ObservedValueCell {
+): RunResultCell {
if (run.observed_value === null) {
return { label: '-', tooltip: null }
}
@@ -147,10 +155,14 @@ export function observedValueCell(
if (run.check_type === CheckTypeEnumApi.RowCount) {
return rowCountCell(run.observed_value, run.check_config)
}
- return { label: humanFriendlyNumber(run.observed_value), tooltip: null }
+ const nouns = FAILING_ROW_NOUNS[run.check_type]
+ if (!nouns) {
+ return { label: humanFriendlyNumber(run.observed_value), tooltip: null }
+ }
+ return { label: pluralize(run.observed_value, nouns[0], nouns[1]), tooltip: null }
}
-function freshnessCell(stalenessSeconds: number, config: DataQualityCheckRunApi['check_config']): ObservedValueCell {
+function freshnessCell(stalenessSeconds: number, config: DataQualityCheckRunApi['check_config']): RunResultCell {
const maxAgeMinutes = config?.max_age_minutes
const limit =
typeof maxAgeMinutes === 'number'
@@ -164,8 +176,8 @@ function freshnessCell(stalenessSeconds: number, config: DataQualityCheckRunApi[
}
}
-function rowCountCell(rowCount: number, config: DataQualityCheckRunApi['check_config']): ObservedValueCell {
- const label = `${humanFriendlyNumber(rowCount)} rows`
+function rowCountCell(rowCount: number, config: DataQualityCheckRunApi['check_config']): RunResultCell {
+ const label = pluralize(rowCount, 'row')
const limit = rowCountLimit(config?.min, config?.max)
return { label, tooltip: limit ? `${label}. The limit is ${limit}.` : null }
}
diff --git a/products/data_quality/frontend/overview/DataQualityOverview.tsx b/products/data_quality/frontend/overview/DataQualityOverview.tsx
index 55bb65e56ca7..ecadc7045b75 100644
--- a/products/data_quality/frontend/overview/DataQualityOverview.tsx
+++ b/products/data_quality/frontend/overview/DataQualityOverview.tsx
@@ -407,7 +407,6 @@ function SubjectChecks({ group }: { group: SubjectGroup }): JSX.Element {
<div className="flex flex-col gap-2 py-2">
{check.description && <p className="mb-0 text-secondary">{check.description}</p>}
<CheckRunsTable
- subjectType={check.subject_type}
runs={checkRunsByCheckId[check.id] ?? []}
loading={runsLoadingByCheckId[check.id]}
/>