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.

perf(dashboards): virtualize columns for hoqgl tables on dashboards (#122209)

Matt Puac95f4f0e6cf6
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Table.render.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Table.render.test.tsx
new file mode 100644
index 000000000000..43c8513916e2
--- /dev/null
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Table.render.test.tsx
@@ -0,0 +1,260 @@
+import { MOCK_DEFAULT_USER } from 'lib/api.mock'
+
+import '@testing-library/jest-dom'
+
+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { BindLogic } from 'kea'
+
+import * as hog from 'lib/hog'
+import { themeLogic } from 'lib/logic/themeLogic'
+import { userLogic } from 'scenes/userLogic'
+
+import {
+ ConditionalFormattingRule,
+ HogQLQueryResponse,
+ NodeKind,
+ VisualizationNode,
+} from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+import { ChartDisplayType } from '~/types'
+
+import { HogQLBoldNumber } from 'products/product_analytics/frontend/insights/shared/BoldNumber/BoldNumber'
+
+import { dataNodeLogic } from '../../DataNode/dataNodeLogic'
+import { dataVisualizationLogic } from '../dataVisualizationLogic'
+import { Table } from './Table'
+
+const response: HogQLQueryResponse = {
+ columns: ['region', 'value'],
+ types: [
+ ['region', 'String'],
+ ['value', 'Float64'],
+ ],
+ results: [
+ ['US', 10],
+ ['EU', 0],
+ ],
+}
+
+const query: VisualizationNode = {
+ kind: NodeKind.DataVisualizationNode,
+ source: { kind: NodeKind.HogQLQuery, query: 'select region, value from results' },
+ display: ChartDisplayType.ActionsTable,
+ tableSettings: {
+ columns: [{ column: 'region' }, { column: 'value', settings: { formatting: { prefix: 'USD ' } } }],
+ },
+}
+
+function mountResult(
+ node: VisualizationNode,
+ cachedResults: HogQLQueryResponse
+): {
+ logic: ReturnType<typeof dataVisualizationLogic.build>
+ props: { key: string; dataNodeCollectionId: string; query: VisualizationNode; cachedResults: HogQLQueryResponse }
+ sourceProps: {
+ key: string
+ dataNodeCollectionId: string
+ query: VisualizationNode['source']
+ cachedResults: HogQLQueryResponse
+ }
+} {
+ const props = {
+ key: 'table-removal-regression',
+ dataNodeCollectionId: 'table-removal-regression',
+ query: node,
+ cachedResults,
+ }
+ const sourceProps = { ...props, query: node.source }
+ dataNodeLogic(sourceProps).mount()
+ const logic = dataVisualizationLogic(props)
+ logic.mount()
+ return { logic, props, sourceProps }
+}
+
+describe('SQL table rendering', () => {
+ beforeEach(() => initKeaTests())
+ afterEach(cleanup)
+
+ it.each([false, true])('inspects the original row after sorting or transposing, transpose=%s', (transpose) => {
+ const node = { ...query, tableSettings: { ...query.tableSettings, transpose } }
+ const { props, sourceProps } = mountResult(node, response)
+ const onInspect = jest.fn()
+ render(
+ <BindLogic logic={dataNodeLogic} props={sourceProps}>
+ <BindLogic logic={dataVisualizationLogic} props={props}>
+ <Table
+ query={node}
+ uniqueKey={props.key}
+ context={{}}
+ cachedResults={response}
+ onInspect={onInspect}
+ />
+ </BindLogic>
+ </BindLogic>
+ )
+ if (!transpose) {
+ fireEvent.click(screen.getByText('region').closest('.LemonTable__header-content')!)
+ }
+ expect(screen.getByText('EU').closest('tbody')!.querySelector('tr[data-row-key]')).toHaveTextContent(
+ transpose ? 'US' : 'EU'
+ )
+ fireEvent.click(screen.getByText('USD 10').closest('button')!)
+ expect(onInspect).toHaveBeenLastCalledWith({ region: 'US', value: 10 })
+ fireEvent.click(screen.getByText('USD 0').closest('button')!)
+ expect(onInspect).toHaveBeenLastCalledWith({ region: 'EU', value: 0 })
+ })
+
+ it('updates conditional cell colors when rules and results change', async () => {
+ const rule: ConditionalFormattingRule = {
+ id: 'equals',
+ templateId: 'equals',
+ columnName: 'value',
+ input: '10',
+ color: '#FFADAD',
+ colorMode: 'light',
+ bytecode: ['_H', 1, 32, 'input', 1, 1, 32, 'value', 1, 1, 11, 38],
+ }
+ const node = { ...query, tableSettings: { ...query.tableSettings, conditionalFormatting: [rule] } }
+ const { logic, props, sourceProps } = mountResult(node, response)
+ userLogic.actions.loadUserSuccess({ ...MOCK_DEFAULT_USER, theme_mode: 'light' })
+ logic.actions.setHogVm(hog)
+ render(
+ <BindLogic logic={dataNodeLogic} props={sourceProps}>
+ <BindLogic logic={dataVisualizationLogic} props={props}>
+ <Table query={node} uniqueKey={props.key} context={{}} cachedResults={response} />
+ </BindLogic>
+ </BindLogic>
+ )
+ await waitFor(() =>
+ expect(screen.getByText('USD 10').closest('td')).toHaveStyle({ backgroundColor: '#FFADAD' })
+ )
+ expect(screen.getByText('USD 0').closest('td')).not.toHaveStyle({ backgroundColor: '#FFADAD' })
+
+ act(() =>
+ logic.actions._setQuery({
+ ...node,
+ tableSettings: { ...node.tableSettings, conditionalFormatting: [{ ...rule, color: '#CAFFBF' }] },
+ })
+ )
+ expect(screen.getByText('USD 10').closest('td')).toHaveStyle({ backgroundColor: '#CAFFBF' })
+
+ act(() =>
+ dataNodeLogic(sourceProps).actions.setResponse({
+ ...response,
+ results: [
+ ['US', 0],
+ ['EU', 10],
+ ],
+ })
+ )
+ expect(screen.getByText('USD 10').closest('td')).toHaveStyle({ backgroundColor: '#CAFFBF' })
+ expect(screen.getByText('USD 0').closest('td')).not.toHaveStyle({ backgroundColor: '#CAFFBF' })
+ act(() => userLogic.actions.loadUserSuccess({ ...MOCK_DEFAULT_USER, theme_mode: 'dark' }))
+ expect(themeLogic.values.isDarkModeOn).toBe(true)
+ expect(screen.getByText('USD 10').closest('td')).not.toHaveStyle({ backgroundColor: '#CAFFBF' })
+ act(() => userLogic.actions.loadUserSuccess({ ...MOCK_DEFAULT_USER, theme_mode: 'light' }))
+ expect(screen.getByText('USD 10').closest('td')).toHaveStyle({ backgroundColor: '#CAFFBF' })
+ })
+
+ it('does not format cells on every sort comparison', () => {
+ const localeFormat = jest.spyOn(Number.prototype, 'toLocaleString').mockImplementation(function (this: number) {
+ return String(this.valueOf())
+ })
+ const rowCount = 1000
+ const result: HogQLQueryResponse = {
+ columns: ['value'],
+ types: [['value', 'Float64']],
+ results: Array.from({ length: rowCount }, (_, index) => [(index * 7919 + 17) % rowCount]),
+ }
+ const node = {
+ ...query,
+ tableSettings: { columns: [{ column: 'value', settings: { formatting: { style: 'number' as const } } }] },
+ }
+ try {
+ const { props, sourceProps } = mountResult(node, result)
+ const { container } = render(
+ <BindLogic logic={dataNodeLogic} props={sourceProps}>
+ <BindLogic logic={dataVisualizationLogic} props={props}>
+ <Table query={node} uniqueKey={props.key} context={{}} cachedResults={result} />
+ </BindLogic>
+ </BindLogic>
+ )
+ localeFormat.mockClear()
+ fireEvent.click(screen.getByText('value').closest('.LemonTable__header-content')!)
+ expect(container.querySelector('tbody tr[data-row-key]')).toHaveTextContent('0')
+ expect(localeFormat.mock.calls.length).toBeGreaterThan(0)
+ expect(localeFormat.mock.calls.length).toBeLessThanOrEqual(rowCount * 3)
+
+ act(() =>
+ dataNodeLogic(sourceProps).actions.setResponse({
+ ...result,
+ results: Array.from({ length: rowCount }, (_, index) => [-index]),
+ })
+ )
+ expect(container.querySelector('tbody tr[data-row-key]')).toHaveTextContent('-999')
+ } finally {
+ cleanup()
+ localeFormat.mockRestore()
+ }
+ })
+
+ it.each([
+ { embedded: true, virtualized: false, pinned: false },
+ { embedded: false, virtualized: true, pinned: false },
+ { embedded: true, virtualized: true, pinned: true },
+ ])('keeps the full column layout for $embedded/$virtualized/$pinned', ({ embedded, virtualized, pinned }) => {
+ const height = jest.spyOn(HTMLElement.prototype, 'offsetHeight', 'get').mockReturnValue(180)
+ const width = jest.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(800)
+ const columns = Array.from({ length: 60 }, (_, index) => `column_${index}`)
+ const result: HogQLQueryResponse = {
+ columns,
+ types: columns.map((column) => [column, 'String']),
+ results: [columns.map((_, index) => `value_${index}`)],
+ }
+ const node = {
+ ...query,
+ tableSettings: { pinnedColumns: pinned ? [columns[0]] : [] },
+ }
+ try {
+ const { props, sourceProps } = mountResult(node, result)
+ const { container } = render(
+ <BindLogic logic={dataNodeLogic} props={sourceProps}>
+ <BindLogic logic={dataVisualizationLogic} props={props}>
+ <Table
+ query={node}
+ uniqueKey={props.key}
+ context={{ dataVisualizationTableVirtualized: virtualized }}
+ cachedResults={result}
+ embedded={embedded}
+ />
+ </BindLogic>
+ </BindLogic>
+ )
+ expect(container.querySelectorAll('tbody td:not([aria-hidden])')).toHaveLength(60)
+ expect(screen.getByText('value_59')).toBeVisible()
+ } finally {
+ cleanup()
+ height.mockRestore()
+ width.mockRestore()
+ }
+ })
+
+ it.each([
+ { results: [[10]], expected: 'USD 10' },
+ { results: [[0]], expected: 'USD 0' },
+ { results: [], expected: null },
+ { results: [[null]], expected: null },
+ ])('renders SQL big numbers for $results', ({ results, expected }) => {
+ const node = { ...query, display: ChartDisplayType.BoldNumber }
+ const result: HogQLQueryResponse = { columns: ['value'], types: [['value', 'Float64']], results }
+ const { props, sourceProps } = mountResult(node, result)
+ const { container } = render(
+ <BindLogic logic={dataNodeLogic} props={sourceProps}>
+ <BindLogic logic={dataVisualizationLogic} props={props}>
+ <HogQLBoldNumber />
+ </BindLogic>
+ </BindLogic>
+ )
+ expect(container.querySelector('.BoldNumber__value')?.textContent ?? null).toBe(expected)
+ })
+})
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx
index 564b38ea1470..3b9e2171d714 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx
@@ -19,7 +19,7 @@ import { LoadNext } from '../../DataNode/LoadNext'
import { renderColumn } from '../../DataTable/renderColumn'
import { renderColumnMeta } from '../../DataTable/renderColumnMeta'
import { getContrastingTextClass } from '../colorUtils'
-import { TableDataCell, convertTableValue, dataVisualizationLogic } from '../dataVisualizationLogic'
+import { TableDataCell, TableRow, convertTableValue, dataVisualizationLogic } from '../dataVisualizationLogic'
import { ColumnScalar } from '../types'
interface TableProps {
@@ -152,10 +152,12 @@ export const Table = (props: TableProps): JSX.Element => {
const { isDarkModeOn } = useValues(themeLogic)
const {
- tabularData,
+ tableRows,
+ tableResults,
+ getTableCell,
+ getSourceTableCell,
tabularColumns,
sourceTabularColumns,
- sourceTabularData,
conditionalFormattingRules,
responseLoading,
responseError,
@@ -174,199 +176,205 @@ export const Table = (props: TableProps): JSX.Element => {
const virtualized =
!!props.embedded &&
!!props.context?.dataVisualizationTableVirtualized &&
- tabularData.length * tabularColumns.length > virtualizationCellThreshold
+ tableRows.length * tabularColumns.length > virtualizationCellThreshold
const { toggleColumnPin, setTableSorted } = useActions(dataVisualizationLogic)
const sourceTabularColumnsByName = new Map(sourceTabularColumns.map((column) => [column.column.name, column]))
- const tableColumns: LemonTableColumn<TableDataCell<any>[], any>[] = tabularColumns.map(
- ({ column, settings }, index) => {
- const { title, ...columnMeta } = renderColumnMeta(column.name, props.query, props.context)
- const columnTitle = settings?.display?.label || title || column.name
- const formattedTitle = typeof columnTitle === 'string' ? formatColumnTitle(columnTitle) : columnTitle
- const fullColumnTitle = typeof columnTitle === 'string' ? columnTitle : undefined
+ const tableColumns = tabularColumns.map<LemonTableColumn<TableRow, any>>(({ column, settings }, index) => {
+ const { title, ...columnMeta } = renderColumnMeta(column.name, props.query, props.context)
+ const columnTitle = settings?.display?.label || title || column.name
+ const formattedTitle = typeof columnTitle === 'string' ? formatColumnTitle(columnTitle) : columnTitle
+ const fullColumnTitle = typeof columnTitle === 'string' ? columnTitle : undefined
- const computeConditionalFormattingBackground = (data: TableDataCell<any>[]): string | undefined => {
- const cell = data[index]
-
- if (cell.isTransposedHeader || !hogVm) {
- return undefined
- }
-
- const sourceColumnName = cell.sourceColumnName ?? column.name
- const sourceColumnType = sourceTabularColumnsByName.get(sourceColumnName)?.column.type.name ?? cell.type
- const conditionalFormattingMatches = conditionalFormattingRules
- .filter((n) => n.columnName === sourceColumnName)
- .filter((n) => {
- const isValidHog = !!n.bytecode && n.bytecode.length > 0 && n.bytecode[0] === '_H'
- if (!isValidHog) {
- posthog.captureException(new Error('Invalid hog bytecode for conditional formatting'), {
- formatRule: n,
- })
- }
-
- return isValidHog
- })
- .map((n) => ({
- rule: n,
- result: hogVm.execHog(n.bytecode, {
- globals: {
- value: cell.value,
- input: convertTableValue(n.input, sourceColumnType),
- },
- functions: {},
- maxAsyncSteps: 0,
- }).result,
- }))
- .find((n) => Boolean(n.result))
-
- if (!conditionalFormattingMatches) {
- return undefined
- }
+ const computeConditionalFormattingBackground = (rowIndex: number): string | undefined => {
+ if (!hogVm) {
+ return undefined
+ }
+ const cell = getTableCell(rowIndex, index)
+ if (cell.isTransposedHeader) {
+ return undefined
+ }
- const ruleColor = conditionalFormattingMatches.rule.color
- const colorMode = conditionalFormattingMatches.rule.colorMode ?? 'light'
+ const sourceColumnName = cell.sourceColumnName ?? column.name
+ const sourceColumnType = sourceTabularColumnsByName.get(sourceColumnName)?.column.type.name ?? cell.type
+ const conditionalFormattingMatches = conditionalFormattingRules
+ .filter((n) => n.columnName === sourceColumnName)
+ .filter((n) => {
+ const isValidHog = !!n.bytecode && n.bytecode.length > 0 && n.bytecode[0] === '_H'
+ if (!isValidHog) {
+ posthog.captureException(new Error('Invalid hog bytecode for conditional formatting'), {
+ formatRule: n,
+ })
+ }
- // If the color mode matches the current theme, use the color as it was saved
- if ((colorMode === 'dark' && isDarkModeOn) || (colorMode === 'light' && !isDarkModeOn)) {
- return ruleColor
- }
+ return isValidHog
+ })
+ .map((n) => ({
+ rule: n,
+ result: hogVm.execHog(n.bytecode, {
+ globals: {
+ value: cell.value,
+ input: convertTableValue(n.input, sourceColumnType),
+ },
+ functions: {},
+ maxAsyncSteps: 0,
+ }).result,
+ }))
+ .find((n) => Boolean(n.result))
+
+ if (!conditionalFormattingMatches) {
+ return undefined
+ }
- // If the color mode is dark, but we're in light mode - then lighten the color
- if (colorMode === 'dark' && !isDarkModeOn) {
- return lightenDarkenColor(ruleColor, 30)
- }
+ const ruleColor = conditionalFormattingMatches.rule.color
+ const colorMode = conditionalFormattingMatches.rule.colorMode ?? 'light'
- // If the color mode is light, but we're in dark mode - then darken the color
- return lightenDarkenColor(ruleColor, -30)
+ // If the color mode matches the current theme, use the color as it was saved
+ if ((colorMode === 'dark' && isDarkModeOn) || (colorMode === 'light' && !isDarkModeOn)) {
+ return ruleColor
}
- // The `style` and `className` cell callbacks are invoked independently for the same cell,
- // so memoize per row record to run the HogVM rules (and any captureException) only once.
- // The cache lives in this per-render closure, so it can't go stale across theme/rule changes.
- const backgroundByRecord = new WeakMap<TableDataCell<any>[], string | undefined>()
- const resolveConditionalFormattingBackground = (data: TableDataCell<any>[]): string | undefined => {
- if (backgroundByRecord.has(data)) {
- return backgroundByRecord.get(data)
- }
- const backgroundColor = computeConditionalFormattingBackground(data)
- backgroundByRecord.set(data, backgroundColor)
- return backgroundColor
+ // If the color mode is dark, but we're in light mode - then lighten the color
+ if (colorMode === 'dark' && !isDarkModeOn) {
+ return lightenDarkenColor(ruleColor, 30)
}
- return {
- ...columnMeta,
- key: column.name,
- // Sorting reorders rows, which doesn't make sense once the table is transposed
- // (rows become the original columns), so only offer it in the normal orientation.
- sorter: isTransposed ? undefined : (a, b) => compareTableCells(a[index], b[index]),
- title: (
- <ColumnHeaderTitle formattedTitle={formattedTitle} fullTitle={fullColumnTitle}>
- {isPinningEnabled && (
- <Tooltip title={isColumnPinned(column.name) ? 'Unpin column' : 'Pin column'}>
- <span
- className="inline-flex items-center justify-center cursor-pointer p-1 -m-1"
- onClick={(e) => {
- e.stopPropagation()
- toggleColumnPin(column.name)
- }}
- >
- {isColumnPinned(column.name) ? (
- <IconPinFilled className="text-sm" />
- ) : (
- <IconPin className="text-sm" />
- )}
- </span>
- </Tooltip>
- )}
- </ColumnHeaderTitle>
- ),
- render: (_, data, recordIndex: number, rowCount: number) => {
- const cell = data[index]
-
- if (cell.isTransposedHeader) {
- const sourceColumnTitle = cell.sourceColumnName
- ? getDisplayedColumnTitle(
- cell.sourceColumnName,
- sourceTabularColumnsByName.get(cell.sourceColumnName)?.settings?.display?.label,
- props.query,
- props.context
- )
- : cell.formattedValue
- const renderedSourceColumnTitle =
- typeof sourceColumnTitle === 'string'
- ? formatColumnTitle(sourceColumnTitle)
- : React.isValidElement(sourceColumnTitle) ||
- sourceColumnTitle == null ||
- typeof sourceColumnTitle === 'number'
- ? sourceColumnTitle
- : String(sourceColumnTitle)
-
- return (
- <div
- className="truncate"
- title={typeof sourceColumnTitle === 'string' ? sourceColumnTitle : undefined}
- >
- {renderedSourceColumnTitle}
- </div>
- )
- }
+ // If the color mode is light, but we're in dark mode - then darken the color
+ return lightenDarkenColor(ruleColor, -30)
+ }
- if (props.onInspect) {
- const sourceRow = isTransposed ? sourceTabularData[index - 1] : data
- const sourceColumns = isTransposed ? sourceTabularColumns : tabularColumns
- return (
- <LemonButton
- type="tertiary"
- size="xsmall"
- // The negative margin cancels the button padding, so the value lines up with the header text
- className="-mx-1.5 max-w-[calc(100%+0.75rem)] !text-inherit"
- tooltip="Explore this result"
- onClick={() =>
- props.onInspect?.(
- Object.fromEntries(
- sourceColumns.map((column, index) => [
- column.column.name,
- sourceRow[index]?.value,
- ])
- )
- )
- }
+ // The style and class callbacks run separately. Cache the last row to avoid a second HogVM call
+ // without retaining offscreen rows. A new column closure invalidates the cache when the theme or rules change.
+ let backgroundRowIndex: number | undefined
+ let backgroundColor: string | undefined
+ const resolveConditionalFormattingBackground = (rowIndex: number): string | undefined => {
+ if (backgroundRowIndex !== rowIndex) {
+ backgroundColor = computeConditionalFormattingBackground(rowIndex)
+ backgroundRowIndex = rowIndex
+ }
+ return backgroundColor
+ }
+
+ let sortCells: TableDataCell<any>[] | undefined
+
+ return {
+ ...columnMeta,
+ key: column.name,
+ // Sorting reorders rows, which doesn't make sense once the table is transposed
+ // (rows become the original columns), so only offer it in the normal orientation.
+ sorter: isTransposed
+ ? undefined
+ : (a, b) => {
+ sortCells ??= tableRows.map((row) => getTableCell(row.rowIndex, index))
+ return compareTableCells(sortCells[a.rowIndex], sortCells[b.rowIndex])
+ },
+ title: (
+ <ColumnHeaderTitle formattedTitle={formattedTitle} fullTitle={fullColumnTitle}>
+ {isPinningEnabled && (
+ <Tooltip title={isColumnPinned(column.name) ? 'Unpin column' : 'Pin column'}>
+ <span
+ className="inline-flex items-center justify-center cursor-pointer p-1 -m-1"
+ onClick={(e) => {
+ e.stopPropagation()
+ toggleColumnPin(column.name)
+ }}
>
- <span className="truncate">{String(cell.formattedValue ?? '—')}</span>
- </LemonButton>
- )
- }
+ {isColumnPinned(column.name) ? (
+ <IconPinFilled className="text-sm" />
+ ) : (
+ <IconPin className="text-sm" />
+ )}
+ </span>
+ </Tooltip>
+ )}
+ </ColumnHeaderTitle>
+ ),
+ render: (_, data, recordIndex: number, rowCount: number) => {
+ const cell = getTableCell(data.rowIndex, index)
+
+ if (cell.isTransposedHeader) {
+ const sourceColumnTitle = cell.sourceColumnName
+ ? getDisplayedColumnTitle(
+ cell.sourceColumnName,
+ sourceTabularColumnsByName.get(cell.sourceColumnName)?.settings?.display?.label,
+ props.query,
+ props.context
+ )
+ : cell.formattedValue
+ const renderedSourceColumnTitle =
+ typeof sourceColumnTitle === 'string'
+ ? formatColumnTitle(sourceColumnTitle)
+ : React.isValidElement(sourceColumnTitle) ||
+ sourceColumnTitle == null ||
+ typeof sourceColumnTitle === 'number'
+ ? sourceColumnTitle
+ : String(sourceColumnTitle)
return (
- <div className="truncate" title={getCellTitle(cell)}>
- {renderColumn(
- cell.sourceColumnName ?? column.name,
- cell.formattedValue,
- data,
- recordIndex,
- rowCount,
- {
- kind: NodeKind.DataTableNode,
- source: props.query.source,
- }
- )}
+ <div
+ className="truncate"
+ title={typeof sourceColumnTitle === 'string' ? sourceColumnTitle : undefined}
+ >
+ {renderedSourceColumnTitle}
</div>
)
- },
- style: (_, data) => {
- const backgroundColor = resolveConditionalFormattingBackground(data)
- return backgroundColor ? { backgroundColor } : undefined
- },
- className: (_, data) => {
- const backgroundColor = resolveConditionalFormattingBackground(data)
- // Pin the text color to the cell background rather than inheriting the theme's text
- // color, which is near-white in dark mode and unreadable on light backgrounds
- return backgroundColor ? getContrastingTextClass(backgroundColor) : ''
- },
- }
+ }
+
+ if (props.onInspect) {
+ const sourceRowIndex = isTransposed ? index - 1 : data.rowIndex
+ const sourceColumns = isTransposed ? sourceTabularColumns : tabularColumns
+ return (
+ <LemonButton
+ type="tertiary"
+ size="xsmall"
+ // The negative margin cancels the button padding, so the value lines up with the header text
+ className="-mx-1.5 max-w-[calc(100%+0.75rem)] !text-inherit"
+ tooltip="Explore this result"
+ onClick={() =>
+ props.onInspect?.(
+ Object.fromEntries(
+ sourceColumns.map((column, index) => [
+ column.column.name,
+ getSourceTableCell(sourceRowIndex, index).value,
+ ])
+ )
+ )
+ }
+ >
+ <span className="truncate">{String(cell.formattedValue ?? '—')}</span>
+ </LemonButton>
+ )
+ }
+
+ return (
+ <div className="truncate" title={getCellTitle(cell)}>
+ {renderColumn(
+ cell.sourceColumnName ?? column.name,
+ cell.formattedValue,
+ tableResults[isTransposed ? index - 1 : data.rowIndex],
+ recordIndex,
+ rowCount,
+ {
+ kind: NodeKind.DataTableNode,
+ source: props.query.source,
+ }
+ )}
+ </div>
+ )
+ },
+ style: (_, data) => {
+ const backgroundColor = resolveConditionalFormattingBackground(data.rowIndex)
+ return backgroundColor ? { backgroundColor } : undefined
+ },
+ className: (_, data) => {
+ const backgroundColor = resolveConditionalFormattingBackground(data.rowIndex)
+ // Pin the text color to the cell background rather than inheriting the theme's text
+ // color, which is near-white in dark mode and unreadable on light backgrounds
+ return backgroundColor ? getContrastingTextClass(backgroundColor) : ''
+ },
}
- )
+ })
return (
<>
@@ -387,7 +395,8 @@ export const Table = (props: TableProps): JSX.Element => {
)}
<LemonTable
className="DataVisualizationTable"
- dataSource={tabularData}
+ rowKey="rowIndex"
+ dataSource={tableRows}
columns={tableColumns}
pinnedColumns={isPinningEnabled ? pinnedColumns : undefined}
loading={responseLoading}
@@ -420,12 +429,12 @@ export const Table = (props: TableProps): JSX.Element => {
/>
)
}
- footer={tabularData.length > 0 ? <LoadNext query={props.query} /> : null}
+ footer={tableRows.length > 0 ? <LoadNext query={props.query} /> : null}
rowClassName="DataVizRow"
embedded={props.embedded}
allowContentScroll={!!props.embedded}
virtualized={virtualized}
- virtualizedColumnWidth={isTransposed && tabularColumns.length > 50 ? 192 : undefined}
+ virtualizedColumnWidth={(virtualized || isTransposed) && tabularColumns.length > 50 ? 192 : undefined}
tableLayout={virtualized ? 'fixed' : 'auto'}
tableStyle={virtualized ? { minWidth: `${tabularColumns.length * 12}rem` } : undefined}
/>
diff --git a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.test.ts b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.test.ts
index 31cc00c12b04..f2e1054ed170 100644
--- a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.test.ts
+++ b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.test.ts
@@ -167,10 +167,14 @@ describe('dataVisualizationLogic', () => {
},
})
logic.mount()
- expect(logic.values.sourceTabularData.map((row) => row[0].value)).toEqual(results.map((row) => row[0]))
- expect(logic.values.sourceTabularData.slice(0, 2).map((row) => row[0].formattedValue)).toEqual(
- bi ? ['Same', 'Same'] : ['$pageview', 'Pageview']
+ expect(logic.values.tableResults.map((_, row) => logic.values.getSourceTableCell(row, 0).value)).toEqual(
+ results.map((row) => row[0])
)
+ expect(
+ logic.values.tableResults
+ .slice(0, 2)
+ .map((_, row) => logic.values.getSourceTableCell(row, 0).formattedValue)
+ ).toEqual(bi ? ['Same', 'Same'] : ['$pageview', 'Pageview'])
expect(logic.values.xData?.data.slice(0, 2)).toEqual(
bi ? ['$pageview', 'Pageview'] : ['Pageview', 'Pageview']
)
@@ -805,6 +809,78 @@ describe('dataVisualizationLogic', () => {
})
})
+ it.each([ChartDisplayType.ActionsBar, ChartDisplayType.ActionsLineGraph, ChartDisplayType.Metric])(
+ 'restores numeric series when switching from a table to %s and back',
+ async (display) => {
+ const response = {
+ columns: ['day', 'value'],
+ types: [
+ ['day', 'Date'],
+ ['value', 'Float64'],
+ ],
+ results: [
+ ['2026-01-01', 2],
+ ['2026-01-02', 4],
+ ],
+ }
+ dataNodeLogic({ key: testKey, query: defaultQuery.source, dataNodeCollectionId }).actions.setResponse(
+ response
+ )
+ logic.actions.setVisualizationType(ChartDisplayType.ActionsTable)
+ expect(logic.values.yData.every((series) => series.data.length === 0)).toBe(true)
+
+ logic.actions.setVisualizationType(display)
+ await expectLogic(logic).toMatchValues({
+ yData: [expect.objectContaining({ data: [2, 4] })],
+ })
+
+ logic.actions.setVisualizationType(ChartDisplayType.ActionsTable)
+ expect(logic.values.yData.every((series) => series.data.length === 0)).toBe(true)
+ expect(logic.values.getTableCell(0, 1).value).toBe(2)
+ expect(logic.values.tableResults).toEqual(response.results)
+ }
+ )
+
+ it.each([false, true])(
+ 'prepares only requested cells with transpose=%s and uses updated formatting',
+ (transpose) => {
+ logic.actions._setQuery({
+ ...defaultQuery,
+ display: ChartDisplayType.ActionsTable,
+ tableSettings: { transpose, columns: [{ column: 'value' }] },
+ })
+ const visibleValue = jest.fn(() => 7)
+ const hiddenValue = jest.fn(() => {
+ throw new Error('An unused cell was read')
+ })
+ const row = [7, 8]
+ Object.defineProperty(row, 0, { get: visibleValue })
+ Object.defineProperty(row, 1, { get: hiddenValue })
+ dataNodeLogic({ key: testKey, query: defaultQuery.source, dataNodeCollectionId }).actions.setResponse({
+ columns: ['value', 'other'],
+ types: [
+ ['value', 'Int64'],
+ ['other', 'Int64'],
+ ],
+ results: [row],
+ })
+
+ expect(logic.values.tableRows).toHaveLength(transpose ? 2 : 1)
+ expect(logic.values.tabularColumns).toHaveLength(2)
+ expect(logic.values.yData.every((series) => series.data.length === 0)).toBe(true)
+ expect(visibleValue).not.toHaveBeenCalled()
+ expect(hiddenValue).not.toHaveBeenCalled()
+ const columnIndex = transpose ? 1 : 0
+ expect(logic.values.getTableCell(0, columnIndex).formattedValue).toBe('7')
+ expect(visibleValue).toHaveBeenCalledTimes(1)
+ expect(hiddenValue).not.toHaveBeenCalled()
+
+ logic.actions.updateSeries('value', { formatting: { prefix: 'USD ' } })
+ expect(logic.values.getTableCell(0, columnIndex).formattedValue).toBe('USD 7')
+ expect(hiddenValue).not.toHaveBeenCalled()
+ }
+ )
+
it('transposes table results without changing the query source', async () => {
dataNodeLogic({ key: testKey, query: defaultQuery.source, dataNodeCollectionId }).actions.setResponse({
columns: ['region', 'value'],
@@ -823,51 +899,55 @@ describe('dataVisualizationLogic', () => {
await expectLogic(logic).toMatchValues({
isTransposed: true,
isPinningEnabled: false,
- tabularData: [
- [
- {
- value: 'region',
- formattedValue: null,
- type: 'STRING',
- sourceColumnName: 'region',
- isTransposedHeader: true,
- },
- {
- value: 'US',
- formattedValue: 'US',
- type: 'STRING',
- sourceColumnName: 'region',
- },
- {
- value: 'EU',
- formattedValue: 'EU',
- type: 'STRING',
- sourceColumnName: 'region',
- },
- ],
- [
- {
- value: 'value',
- formattedValue: null,
- type: 'STRING',
- sourceColumnName: 'value',
- isTransposedHeader: true,
- },
- {
- value: 10,
- formattedValue: '10',
- type: 'INTEGER',
- sourceColumnName: 'value',
- },
- {
- value: 20,
- formattedValue: '20',
- type: 'INTEGER',
- sourceColumnName: 'value',
- },
- ],
- ],
})
+ expect(
+ logic.values.tableRows.map((row) =>
+ logic.values.tabularColumns.map((_, column) => logic.values.getTableCell(row.rowIndex, column))
+ )
+ ).toEqual([
+ [
+ {
+ value: 'region',
+ formattedValue: null,
+ type: 'STRING',
+ sourceColumnName: 'region',
+ isTransposedHeader: true,
+ },
+ {
+ value: 'US',
+ formattedValue: 'US',
+ type: 'STRING',
+ sourceColumnName: 'region',
+ },
+ {
+ value: 'EU',
+ formattedValue: 'EU',
+ type: 'STRING',
+ sourceColumnName: 'region',
+ },
+ ],
+ [
+ {
+ value: 'value',
+ formattedValue: null,
+ type: 'STRING',
+ sourceColumnName: 'value',
+ isTransposedHeader: true,
+ },
+ {
+ value: 10,
+ formattedValue: '10',
+ type: 'INTEGER',
+ sourceColumnName: 'value',
+ },
+ {
+ value: 20,
+ formattedValue: '20',
+ type: 'INTEGER',
+ sourceColumnName: 'value',
+ },
+ ],
+ ])
expect(logic.values.query.source).toEqual(defaultQuery.source)
expect(logic.values.query.tableSettings?.transpose).toEqual(true)
@@ -1046,9 +1126,7 @@ describe('dataVisualizationLogic', () => {
results: [[12.345]],
})
- await expectLogic(logic).toMatchValues({
- tabularData: [[expect.objectContaining({ value: 12.345, formattedValue: '12.3' })]],
- })
+ expect(logic.values.getTableCell(0, 0)).toMatchObject({ value: 12.345, formattedValue: '12.3' })
})
it.each<[string, number, AxisSeriesSettings | undefined, string]>([
diff --git a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts
index b0e6d4bc4768..24c55c79bb49 100644
--- a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts
+++ b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts
@@ -99,6 +99,10 @@ export interface Column {
dataIndex: number
}
+export interface TableRow {
+ rowIndex: number
+}
+
export interface TableDataCell<T extends string | number | boolean | Date | null> {
value: T
formattedValue: string | object | null
@@ -700,6 +704,8 @@ export interface dataVisualizationLogicValues {
dashboardId: any
dataVisualizationProps: DataVisualizationLogicProps
effectiveVisualizationType: ChartDisplayType
+ getSourceTableCell: (rowIndex: number, columnIndex: number) => TableDataCell<any>
+ getTableCell: (rowIndex: number, columnIndex: number) => TableDataCell<any>
hasDateTimeColumns: boolean
hasMoreData: boolean
hasSortedTable: boolean
@@ -725,10 +731,10 @@ export interface dataVisualizationLogicValues {
showTableSettings: boolean
sourceFeatures: Set<QueryFeature>
sourceTabularColumns: AxisSeries<any>[]
- sourceTabularData: TableDataCell<any>[][]
+ tableResults: HogQLQueryResponse['results']
+ tableRows: TableRow[]
tabularColumnSettings: (SelectedYAxis | null)[] | null
tabularColumns: AxisSeries<any>[]
- tabularData: TableDataCell<any>[][]
visualizationType: ChartDisplayType
xData: AxisSeries<string> | null
yData: AxisSeries<number | null>[]
@@ -927,22 +933,24 @@ export interface dataVisualizationLogicMeta {
response: AnyResponseType | null,
columns: Column[]
) => AxisSeries<any>[]
- sourceTabularData: (
+ tableResults: (response: AnyResponseType | null) => HogQLQueryResponse['results']
+ getSourceTableCell: (
sourceTabularColumns: AxisSeries<any>[],
- response: AnyResponseType | null,
+ tableResults: any[],
chartSettings: ChartSettings,
query: VisualizationNode
- ) => TableDataCell<any>[][]
+ ) => (rowIndex: number, columnIndex: number) => TableDataCell<any>
tabularColumns: (
sourceTabularColumns: AxisSeries<any>[],
- sourceTabularData: TableDataCell<any>[][],
+ tableResults: any[],
isTransposed: boolean
) => AxisSeries<any>[]
- tabularData: (
+ tableRows: (tableResults: any[], sourceTabularColumns: AxisSeries<any>[], isTransposed: boolean) => TableRow[]
+ getTableCell: (
+ getSourceTableCell: (rowIndex: number, columnIndex: number) => TableDataCell<any>,
sourceTabularColumns: AxisSeries<any>[],
- sourceTabularData: TableDataCell<any>[][],
isTransposed: boolean
- ) => TableDataCell<any>[][]
+ ) => (rowIndex: number, columnIndex: number) => TableDataCell<any>
dataVisualizationProps: (arg: any) => DataVisualizationLogicProps
effectiveVisualizationType: (
visualizationType: ChartDisplayType,
@@ -1532,6 +1540,7 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
? response.result
: []
+ const seriesRows = visualizationType === ChartDisplayType.ActionsTable ? [] : data
const mappedSeries = visualizationType === ChartDisplayType.Metric ? ySeries.slice(0, 1) : ySeries
const seriesData = mappedSeries
.map((series): AxisSeries<number | null> | null => {
@@ -1546,7 +1555,7 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
return {
column,
- data: data.map((n) => {
+ data: seriesRows.map((n) => {
try {
const multiplier = series.settings.formatting?.style === 'percent' ? 100 : 1
@@ -1683,40 +1692,27 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
})
},
],
- sourceTabularData: [
- (s) => [s.sourceTabularColumns, s.response, s.chartSettings, s.query],
+ tableResults: [
+ (s) => [s.response],
+ (response: AnyResponseType | null): HogQLQueryResponse['results'] => {
+ if (response && 'results' in response && Array.isArray(response.results)) {
+ return response.results
+ }
+ if (response && 'result' in response && Array.isArray(response.result)) {
+ return response.result
+ }
+ return []
+ },
+ ],
+ getSourceTableCell: [
+ (s) => [s.sourceTabularColumns, s.tableResults, s.chartSettings, s.query],
(
sourceTabularColumns: AxisSeries<any>[],
- response:
- | Record<string, any>
- | null
- | import('~/queries/schema/schema-general').ErrorTrackingQueryResponse
- | import('~/queries/schema/schema-general').HogQLAutocompleteResponse
- | import('~/queries/schema/schema-general').HogQLMetadataResponse
- | import('~/queries/schema/schema-general').HogQLQueryResponse<any[]>
- | import('~/queries/schema/schema-general').HogQueryResponse
- | import('~/queries/schema/schema-general').LogAttributesQueryResponse
- | import('~/queries/schema/schema-general').LogValuesQueryResponse
- | import('~/queries/schema/schema-general').MetricsQueryResponse
- | import('~/queries/schema/schema-general').SessionsQueryResponse
- | import('~/queries/schema/schema-general').TraceSpansAggregationQueryResponse
- | import('~/queries/schema/schema-general').TraceSpansAttributeBreakdownQueryResponse
- | import('~/queries/schema/schema-general').TraceSpansQueryResponse,
+ data: HogQLQueryResponse['results'],
chartSettings: ChartSettings,
query: VisualizationNode
- ): TableDataCell<any>[][] => {
- if (!response) {
- return []
- }
-
+ ): ((rowIndex: number, columnIndex: number) => TableDataCell<any>) => {
const showNullsAsZero = chartSettings.showNullsAsZero ?? false
- const data =
- 'results' in response && Array.isArray(response.results)
- ? response.results
- : 'result' in response && Array.isArray(response.result)
- ? response.result
- : []
-
const dimensions = new Map(
query.kind === NodeKind.BIVisualizationNode
? getBIResultDimensions(query.config).map(({ column, field }) => [column, field])
@@ -1725,89 +1721,88 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
const memberDisplay =
query.kind === NodeKind.BIVisualizationNode ? createBIMemberDisplayLookup(query.config) : undefined
- return data.map((row): TableDataCell<any>[] => {
- return sourceTabularColumns.map((column): TableDataCell<any> => {
- if (!column) {
- return {
- value: null,
- formattedValue: null,
- type: 'STRING',
- }
+ return (rowIndex, columnIndex): TableDataCell<any> => {
+ const column = sourceTabularColumns[columnIndex]
+ if (!column) {
+ return {
+ value: null,
+ formattedValue: null,
+ type: 'STRING',
}
+ }
- const value = row[column.column.dataIndex]
- const dimension = dimensions.get(column.column.name)
- const alias = dimension ? memberDisplay?.(dimension, value) : undefined
- if (alias !== undefined) {
- return { value, formattedValue: alias, type: column.column.type.name }
- }
+ const value = data[rowIndex][column.column.dataIndex]
+ const dimension = dimensions.get(column.column.name)
+ const alias = dimension ? memberDisplay?.(dimension, value) : undefined
+ if (alias !== undefined) {
+ return { value, formattedValue: alias, type: column.column.type.name }
+ }
- if (column.column.type.isNumerical) {
- try {
- if (value === null) {
- const nullReplacement = showNullsAsZero ? 0 : null
+ if (column.column.type.isNumerical) {
+ try {
+ if (value === null) {
+ const nullReplacement = showNullsAsZero ? 0 : null
- return {
- value: nullReplacement,
- formattedValue: formatDataWithSettings(nullReplacement, column.settings),
- type: column.column.type.name,
- }
+ return {
+ value: nullReplacement,
+ formattedValue: formatDataWithSettings(nullReplacement, column.settings),
+ type: column.column.type.name,
}
+ }
- const multiplier = column.settings?.formatting?.style === 'percent' ? 100 : 1
-
- if (
- column.settings?.formatting?.decimalPlaces != null &&
- column.settings.formatting.style !== 'short'
- ) {
- return {
- value,
- formattedValue: formatDataWithSettings(
- parseFloat(
- (parseFloat(value.toString()) * multiplier).toFixed(
- column.settings.formatting.decimalPlaces
- )
- ),
- column.settings
- ),
- type: column.column.type.name,
- }
- }
+ const multiplier = column.settings?.formatting?.style === 'percent' ? 100 : 1
- const isInt = Number.isInteger(value)
+ if (
+ column.settings?.formatting?.decimalPlaces != null &&
+ column.settings.formatting.style !== 'short'
+ ) {
return {
value,
formattedValue: formatDataWithSettings(
- isInt
- ? parseInt(value.toString(), 10) * multiplier
- : parseFloat(value.toString()) * multiplier,
+ parseFloat(
+ (parseFloat(value.toString()) * multiplier).toFixed(
+ column.settings.formatting.decimalPlaces
+ )
+ ),
column.settings
),
type: column.column.type.name,
}
- } catch {
- return {
- value: 0,
- formattedValue: '0',
- type: column.column.type.name,
- }
}
- }
- return {
- value: convertTableValue(value, column.column.type.name),
- formattedValue: formatDataWithSettings(value, column.settings),
- type: column.column.type.name,
+ const isInt = Number.isInteger(value)
+ return {
+ value,
+ formattedValue: formatDataWithSettings(
+ isInt
+ ? parseInt(value.toString(), 10) * multiplier
+ : parseFloat(value.toString()) * multiplier,
+ column.settings
+ ),
+ type: column.column.type.name,
+ }
+ } catch {
+ return {
+ value: 0,
+ formattedValue: '0',
+ type: column.column.type.name,
+ }
}
- })
- })
+ }
+
+ return {
+ value: convertTableValue(value, column.column.type.name),
+ formattedValue: formatDataWithSettings(value, column.settings),
+ type: column.column.type.name,
+ }
+ }
},
],
tabularColumns: [
- (s) => [s.sourceTabularColumns, s.sourceTabularData, s.isTransposed],
+ (s) => [s.sourceTabularColumns, s.tableResults, s.isTransposed],
(
sourceTabularColumns: AxisSeries<any>[],
- sourceTabularData: TableDataCell<any>[][],
+ tableResults: HogQLQueryResponse['results'],
isTransposed: boolean
): AxisSeries<any>[] => {
if (!isTransposed) {
@@ -1837,7 +1832,8 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
},
},
},
- ...sourceTabularData.map(
+ ...Array.from(
+ { length: tableResults.length },
(_, index): AxisSeries<any> => ({
column: {
name: `${TRANSPOSED_ROW_COLUMN_PREFIX}${index}`,
@@ -1860,36 +1856,41 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
]
},
],
- tabularData: [
- (s) => [s.sourceTabularColumns, s.sourceTabularData, s.isTransposed],
- (
- sourceTabularColumns: AxisSeries<any>[],
- sourceTabularData: TableDataCell<any>[][],
- isTransposed: boolean
- ): TableDataCell<any>[][] => {
- if (!isTransposed) {
- return sourceTabularData
- }
-
- if (sourceTabularData.length === 0) {
+ tableRows: [
+ (s) => [s.tableResults, s.sourceTabularColumns, s.isTransposed],
+ (results: HogQLQueryResponse['results'], columns: AxisSeries<any>[], isTransposed: boolean): TableRow[] => {
+ if (results.length === 0) {
return []
}
-
- return sourceTabularColumns.map((column, columnIndex) => [
- {
- value: column.column.name,
- formattedValue: null,
- type: 'STRING',
- sourceColumnName: column.column.name,
- isTransposedHeader: true,
- },
- ...sourceTabularData.map((row) => ({
- ...row[columnIndex],
- sourceColumnName: column.column.name,
- })),
- ])
+ return Array.from({ length: isTransposed ? columns.length : results.length }, (_, rowIndex) => ({
+ rowIndex,
+ }))
},
],
+ getTableCell: [
+ (s) => [s.getSourceTableCell, s.sourceTabularColumns, s.isTransposed],
+ (
+ getSourceTableCell: (rowIndex: number, columnIndex: number) => TableDataCell<any>,
+ columns: AxisSeries<any>[],
+ isTransposed: boolean
+ ): ((rowIndex: number, columnIndex: number) => TableDataCell<any>) =>
+ (rowIndex, columnIndex): TableDataCell<any> => {
+ if (!isTransposed) {
+ return getSourceTableCell(rowIndex, columnIndex)
+ }
+ const sourceColumnName = columns[rowIndex].column.name
+ if (columnIndex === 0) {
+ return {
+ value: sourceColumnName,
+ formattedValue: null,
+ type: 'STRING',
+ sourceColumnName,
+ isTransposedHeader: true,
+ }
+ }
+ return { ...getSourceTableCell(columnIndex - 1, rowIndex), sourceColumnName }
+ },
+ ],
dataVisualizationProps: [() => [(_, props) => props], (props): DataVisualizationLogicProps => props],
effectiveVisualizationType: [
(s) => [s.visualizationType, s.autoVisualizationType],
diff --git a/products/dashboards/PERFORMANCE.md b/products/dashboards/PERFORMANCE.md
index 82665e0f55fb..4319abc0191a 100644
--- a/products/dashboards/PERFORMANCE.md
+++ b/products/dashboards/PERFORMANCE.md
@@ -154,6 +154,13 @@ Mode changes and virtualization must not accidentally invalidate queries or star
A fast network response can still cause a slow interface if parsing, state propagation, or rendering is expensive.
A slow request does not explain a delayed local drag unless the interaction actually waits for it.
+SQL result tables in dashboard cards use row virtualization inside the tile's scroll area.
+Tables with more than 50 columns also use column virtualization with fixed column widths, unless pinned columns require the full column layout.
+Image exports keep the full table layout.
+Table renderers prepare cells by row and column index, including transposed cells, so offscreen cells do not require formatting before display.
+Sorting prepares the selected column once per column configuration; comparisons reuse those cells.
+Tables skip chart aggregation. Virtualization does not reduce query result size or response parsing.
+
## Measure the affected experience
Respect the user's constraints on runtime checks, tests, and publishing.
diff --git a/products/product_analytics/frontend/insights/shared/BoldNumber/BoldNumber.tsx b/products/product_analytics/frontend/insights/shared/BoldNumber/BoldNumber.tsx
index d72235964dda..bafb159100bb 100644
--- a/products/product_analytics/frontend/insights/shared/BoldNumber/BoldNumber.tsx
+++ b/products/product_analytics/frontend/insights/shared/BoldNumber/BoldNumber.tsx
@@ -273,7 +273,7 @@ function BoldNumberComparison({
}
export function HogQLBoldNumber(): JSX.Element {
- const { response, responseLoading, tabularData } = useValues(dataVisualizationLogic)
+ const { response, responseLoading, tableRows, getTableCell } = useValues(dataVisualizationLogic)
if (!response || responseLoading) {
return (
@@ -287,7 +287,7 @@ export function HogQLBoldNumber(): JSX.Element {
)
}
- const formattedValue = tabularData[0]?.[0]?.formattedValue ?? null
+ const formattedValue = tableRows.length > 0 ? getTableCell(0, 0).formattedValue : null
const directValue = Array.isArray(response) ? response[0]?.[0] : undefined
const resultsValue = 'results' in response ? response.results?.[0]?.[0] : undefined
const resultValue = 'result' in response ? response.result?.[0]?.[0] : undefined