: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add BI limits and pivot tables (#79606)
Marius Andra25ffeecf3678
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Heatmap/TwoDimensionalHeatmap.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Heatmap/TwoDimensionalHeatmap.test.tsxindex 4804ac36f3ae..240222424dcb 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Heatmap/TwoDimensionalHeatmap.test.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/Heatmap/TwoDimensionalHeatmap.test.tsx@@ -140,4 +140,19 @@ describe('TwoDimensionalHeatmap', () => {expect(await screen.findAllByText('(cell null)')).toHaveLength(2)expect(await screen.findAllByText('(header null)')).toHaveLength(2)})++ it('does not render a dense grid when sparse results produce too many cells', async () => {+ const sparseResponse = {+ ...response,+ results: Array.from({ length: 101 }, (_, index) => [`Region ${index}`, `Segment ${index}`, index]),+ }++ setup('(header null)', '', sparseResponse)++ expect(await screen.findByText('Too many cells to display')).toBeInTheDocument()+ expect(+ screen.getByText('Use columns with fewer unique values or reduce the query result size.')+ ).toBeInTheDocument()+ expect(screen.queryByRole('table')).not.toBeInTheDocument()+ })})diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Heatmap/TwoDimensionalHeatmap.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Heatmap/TwoDimensionalHeatmap.tsxindex 9f0f4d79b1f3..691dd2584c6a 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Heatmap/TwoDimensionalHeatmap.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/Heatmap/TwoDimensionalHeatmap.tsx@@ -48,8 +48,11 @@ type HeatmapData = {cellValues: Record<string, Record<string, number | null>>numericValues: number[]duplicateCellCount: number+ isTooLarge: boolean}+const MAX_HEATMAP_CELLS = 10_000+type HeatmapDataSettings = Pick<HeatmapSettings,'xAxisColumn' | 'yAxisColumn' | 'valueColumn' | 'nullLabel' | 'nullValue'@@ -79,6 +82,7 @@ const buildHeatmapData = (cellValues,numericValues,duplicateCellCount,+ isTooLarge: false,}}@@ -115,14 +119,16 @@ const buildHeatmapData = (cellValues[yLabel][xLabel] = numericValue})- yValues.forEach((yValue) => {- xValues.forEach((xValue) => {- const cellValue = cellValues[yValue]?.[xValue]- if (cellValue !== null && cellValue !== undefined) {- numericValues.push(cellValue)- }+ const isTooLarge = xValues.length * yValues.length > MAX_HEATMAP_CELLS+ if (!isTooLarge) {+ yValues.forEach((yValue) => {+ Object.values(cellValues[yValue]).forEach((cellValue) => {+ if (cellValue !== null && cellValue !== undefined) {+ numericValues.push(cellValue)+ }+ })})- })+ }return {xValues,@@ -130,6 +136,7 @@ const buildHeatmapData = (cellValues,numericValues,duplicateCellCount,+ isTooLarge,}}@@ -194,6 +201,7 @@ export function TwoDimensionalHeatmap({ allowSorting = true }: { allowSorting?:cellValues: {},numericValues: [],duplicateCellCount: 0,+ isTooLarge: false,}}@@ -256,6 +264,17 @@ export function TwoDimensionalHeatmap({ allowSorting = true }: { allowSorting?:)}+ if (heatmapData.isTooLarge) {+ return (+ <div className="flex items-center justify-center h-full">+ <InsightEmptyState+ heading="Too many cells to display"+ detail="Use columns with fewer unique values or reduce the query result size."+ />+ </div>+ )+ }+return (<div className="flex flex-col gap-2 p-2">{heatmapData.duplicateCellCount > 0 && (diff --git a/frontend/src/scenes/data-warehouse/editor/bi/BIEditor.tsx b/frontend/src/scenes/data-warehouse/editor/bi/BIEditor.tsxindex 1079b9055cfa..dc410c6cd5b5 100644--- a/frontend/src/scenes/data-warehouse/editor/bi/BIEditor.tsx+++ b/frontend/src/scenes/data-warehouse/editor/bi/BIEditor.tsx@@ -32,9 +32,11 @@ import {BIAggregation,BIDateBucket,BI_FIELD_DRAG_MIME_TYPE,+ BI_QUERY_LIMITS,BIFilterOperator,BIShelf,BIField,+ PIVOT_TABLE_QUERY_LIMIT,getBIDataSourceKey,isDateTimeBIField,isNumericBIField,@@ -49,7 +51,7 @@ const CHART_TYPE_OPTIONS: { value: ChartDisplayType; label: string; icon: JSX.El{ value: ChartDisplayType.ActionsStackedBar, label: 'Stacked bar chart', icon: <IconLifecycle /> },{ value: ChartDisplayType.ActionsAreaGraph, label: 'Area chart', icon: <IconAreaChart /> },{ value: ChartDisplayType.ActionsPie, label: 'Pie chart', icon: <IconPieChart /> },- { value: ChartDisplayType.TwoDimensionalHeatmap, label: '2D heatmap', icon: <IconHeatmap /> },+ { value: ChartDisplayType.TwoDimensionalHeatmap, label: 'Pivot table', icon: <IconHeatmap /> },{ value: ChartDisplayType.BoldNumber, label: 'Big number', icon: <Icon123 /> },]@@ -86,6 +88,11 @@ const DATE_BUCKET_OPTIONS: { value: BIDateBucket | null; label: string }[] = [{ value: 'year', label: 'Year' },]+const LIMIT_OPTIONS = BI_QUERY_LIMITS.map((limit) => ({+ value: limit,+ label: limit === 1000 ? '1k' : limit === 10000 ? '10k' : limit === 50000 ? '50k' : String(limit),+}))+export function BIEditor({ tabId }: { tabId: string }): JSX.Element {const logic = biEditorLogic({ tabId })const { activeDropShelf, activeExpressionEditorId, availableDataSources, config, databaseLoading } =@@ -108,9 +115,14 @@ export function BIEditor({ tabId }: { tabId: string }): JSX.Element {setFilterCustomExpression,setFilterOperator,setFilterValue,+ setLimit,setValueAggregation,setValueCustomExpression,} = useActions(logic)+ const limitOptions =+ config.chartType === ChartDisplayType.TwoDimensionalHeatmap+ ? LIMIT_OPTIONS.filter(({ value }) => value <= PIVOT_TABLE_QUERY_LIMIT)+ : LIMIT_OPTIONSreturn (<div@@ -171,6 +183,16 @@ export function BIEditor({ tabId }: { tabId: string }): JSX.Element {dropdownMaxContentWidthdata-attr="bi-editor-data-source"/>+ <LemonSelect+ value={config.limit}+ options={limitOptions}+ onChange={setLimit}+ renderButtonContent={(option) => `Limit: ${option?.label ?? config.limit}`}+ aria-label="Query row limit"+ size="small"+ dropdownMatchSelectWidth={false}+ data-attr="bi-editor-query-limit"+ /><LemonButtontype="secondary"size="small"diff --git a/frontend/src/scenes/data-warehouse/editor/bi/biEditorLogic.ts b/frontend/src/scenes/data-warehouse/editor/bi/biEditorLogic.tsindex b9dcb5d23b6f..543958f2e5f6 100644--- a/frontend/src/scenes/data-warehouse/editor/bi/biEditorLogic.ts+++ b/frontend/src/scenes/data-warehouse/editor/bi/biEditorLogic.ts@@ -19,12 +19,14 @@ import {BIField,BIFilterOperator,BIQueryBuildResult,+ BIQueryLimit,BIShelf,DEFAULT_BI_CONFIG,buildBIQuery,createDefaultDateFilter,defaultAggregationForField,isBIFieldCompatible,+ normalizeBIConfig,} from './biEditorTypes'export interface BIEditorLogicProps {@@ -297,6 +299,9 @@ export interface biEditorLogicActions {index: numbervalue: string}+ setLimit: (limit: BIQueryLimit) => {+ limit: 100 | 1000 | 10000 | 50000+ }setValueAggregation: (index: number,aggregation: BIAggregation@@ -364,6 +369,7 @@ export const biEditorLogic = kea<biEditorLogicType>([setValueAggregation: (index: number, aggregation: BIAggregation) => ({ index, aggregation }),setFilterOperator: (index: number, operator: BIFilterOperator) => ({ index, operator }),setFilterValue: (index: number, value: string) => ({ index, value }),+ setLimit: (limit: BIQueryLimit) => ({ limit }),setFieldExpression: (shelf: BIShelf, index: number, expression: string) => ({ shelf, index, expression }),setFieldDateBucket: (shelf: BIShelf, index: number, dateBucket: BIDateBucket | null) => ({shelf,@@ -411,7 +417,7 @@ export const biEditorLogic = kea<biEditorLogicType>([addBlankFieldToShelf: (config, { shelf, fieldId }) =>config.source ? addFieldToConfig(config, blankField(config.source, fieldId), shelf) : config,removeFieldFromShelf: (config, { shelf, index }) => removeFieldFromConfig(config, shelf, index),- setChartType: (config, { chartType }) => ({ ...config, chartType }),+ setChartType: (config, { chartType }) => normalizeBIConfig({ ...config, chartType }),setDataSource: (config, { source }) => setDataSourceInConfig(config, source),setValueAggregation: (config, { index, aggregation }) => ({...config,@@ -431,6 +437,7 @@ export const biEditorLogic = kea<biEditorLogicType>([filterIndex === index ? { ...filter, value } : filter),}),+ setLimit: (config, { limit }) => normalizeBIConfig({ ...config, limit }),setFieldExpression: (config, { shelf, index, expression }) =>setFieldExpressionInConfig(config, shelf, index, expression),setFieldDateBucket: (config, { shelf, index, dateBucket }) =>@@ -447,9 +454,10 @@ export const biEditorLogic = kea<biEditorLogicType>([filterIndex === index ? { ...filter, customExpression } : filter),}),- restoreState: (_, { state }) => state.config,- persistState: (_, { config }) => config,- updateTab: (_, { tab }) => tab.biEditorState?.config ?? freshBIConfig(),+ restoreState: (_, { state }) => normalizeBIConfig(state.config),+ persistState: (_, { config }) => normalizeBIConfig(config),+ updateTab: (_, { tab }) =>+ tab.biEditorState ? normalizeBIConfig(tab.biEditorState.config) : freshBIConfig(),resetConfig: freshBIConfig,},],@@ -527,6 +535,10 @@ export const biEditorLogic = kea<biEditorLogicType>([actions.persistState(values.editorView, values.config)actions.syncGeneratedQuery()},+ setLimit: () => {+ actions.persistState(values.editorView, values.config)+ actions.syncGeneratedQuery()+ },setFieldExpression: () => {actions.persistState(values.editorView, values.config)actions.syncGeneratedQuery()@@ -570,10 +582,21 @@ export const biEditorLogic = kea<biEditorLogicType>([const editorLogic = sqlEditorLogic({ tabId: logicProps.tabId })const sourceQuery = editorLogic.values.sourceQuery+ const generatedChartSettings = values.generatedQuery.node.chartSettingseditorLogic.actions.setQueryInput(values.generatedQuery.query)editorLogic.actions.setSourceQuery({...sourceQuery,...values.generatedQuery.node,+ chartSettings: generatedChartSettings+ ? {+ ...sourceQuery.chartSettings,+ ...generatedChartSettings,+ heatmap: {+ ...sourceQuery.chartSettings?.heatmap,+ ...generatedChartSettings.heatmap,+ },+ }+ : sourceQuery.chartSettings,source: {...sourceQuery.source,...values.generatedQuery.node.source,diff --git a/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.test.ts b/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.test.tsindex f6a4822331c7..1d9a8121afad 100644--- a/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.test.ts+++ b/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.test.ts@@ -36,6 +36,22 @@ const timestampField: BIField = {source: { table: 'events' },}+const browserField: BIField = {+ id: 'warehouse:events:properties.$browser',+ name: 'browser',+ expression: 'properties.$browser',+ type: 'string',+ source: { table: 'events' },+}++const countryField: BIField = {+ id: 'warehouse:events:properties.$geoip_country_name',+ name: 'country',+ expression: 'properties.$geoip_country_name',+ type: 'string',+ source: { table: 'events' },+}+describe('BI editor query generation', () => {it('builds a visualization node with dimensions, aggregations, and filters', () => {const expectedQuery = [@@ -87,6 +103,33 @@ describe('BI editor query generation', () => {expect(result?.query).toContain('count(*) AS count')})+ it('maps every BI row and column dimension to pivot table axes', () => {+ const result = buildBIQuery({+ source: { table: 'events' },+ chartType: ChartDisplayType.TwoDimensionalHeatmap,+ rows: [eventField, timestampField],+ columns: [browserField, countryField],+ values: [{ field: revenueField, aggregation: 'sum' }],+ filters: [],+ limit: 50000,+ })++ expect(result?.query).toContain('toJSONString(tuple(event, timestamp)) AS bi_rows')+ expect(result?.query).toContain(+ 'toJSONString(tuple(properties.$browser, properties.$geoip_country_name)) AS bi_columns'+ )+ expect(result?.query).toContain('LIMIT 1000')+ expect(result?.node.chartSettings).toEqual({+ heatmap: {+ xAxisColumn: 'bi_columns',+ yAxisColumn: 'bi_rows',+ valueColumn: 'sum_revenue',+ xAxisLabel: 'browser / country',+ yAxisLabel: 'event / timestamp',+ },+ })+ })+it('ignores blank shelf fields until they are configured', () => {const blankField: BIField = {id: 'blank-field',diff --git a/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.ts b/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.tsindex d0f5e448a9d3..e5e96a6dc3c3 100644--- a/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.ts+++ b/frontend/src/scenes/data-warehouse/editor/bi/biEditorTypes.ts@@ -13,6 +13,12 @@ export type BIAggregation = 'count' | 'count_distinct' | 'sum' | 'average' | 'miexport type BIDateBucket = 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'+export const BI_QUERY_LIMITS = [100, 1000, 10000, 50000] as const++export type BIQueryLimit = (typeof BI_QUERY_LIMITS)[number]++export const PIVOT_TABLE_QUERY_LIMIT: BIQueryLimit = 1000+export type BIFilterOperator =| 'equals'| 'not_equals'@@ -66,7 +72,7 @@ export interface BIConfig {columns: BIField[]values: BIValue[]filters: BIFilter[]- limit: number+ limit: BIQueryLimit}export interface BIEditorState {@@ -91,6 +97,14 @@ export const DEFAULT_BI_CONFIG: BIConfig = {limit: 1000,}+export function normalizeBIConfig(config: BIConfig): BIConfig {+ if (config.chartType !== ChartDisplayType.TwoDimensionalHeatmap || config.limit <= PIVOT_TABLE_QUERY_LIMIT) {+ return config+ }++ return { ...config, limit: PIVOT_TABLE_QUERY_LIMIT }+}+const BI_AGGREGATIONS = new Set<BIAggregation>(['count','count_distinct',@@ -308,9 +322,7 @@ export function parseBIEditorState(editorViewValue: unknown, configValue: unknowvalues.some((value) => !value) ||!filters ||filters.some((filter) => !filter) ||- typeof candidate.limit !== 'number' ||- !Number.isInteger(candidate.limit) ||- candidate.limit <= 0+ !BI_QUERY_LIMITS.includes(candidate.limit as BIQueryLimit)) {return null}@@ -322,7 +334,7 @@ export function parseBIEditorState(editorViewValue: unknown, configValue: unknowcolumns: columns as BIField[],values: values as BIValue[],filters: filters as BIFilter[],- limit: candidate.limit,+ limit: candidate.limit as BIQueryLimit,}const fields = [...config.rows,@@ -335,7 +347,7 @@ export function parseBIEditorState(editorViewValue: unknown, configValue: unknowreturn null}- return { editorView: editorViewValue, config }+ return { editorView: editorViewValue, config: normalizeBIConfig(config) }}function sanitizeAlias(value: string): string {@@ -347,6 +359,25 @@ function sanitizeAlias(value: string): string {return alias || 'value'}+function dimensionAlias(shelf: 'row' | 'column', field: BIField, index: number): string {+ return `bi_${shelf}_${sanitizeAlias(field.name || field.expression)}${index > 0 ? `_${index + 1}` : ''}`+}++interface BIDimension {+ alias: string+ field: BIField+}++interface BIPivotAxis {+ alias: string+ expression: string+ label: string+}++function aggregationAlias(value: BIValue, index: number): string {+ return `${value.aggregation}_${sanitizeAlias(value.field.name)}${index > 0 ? `_${index + 1}` : ''}`+}+const DOTTED_IDENTIFIER_REGEX = /^[A-Za-z_$][A-Za-z0-9_$]*(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*$/function fieldExpression(field: BIField): string {@@ -358,6 +389,21 @@ function fieldExpression(field: BIField): string {return field.dateBucket ? `${DATE_BUCKET_FUNCTIONS[field.dateBucket]}(${escapedExpression})` : escapedExpression}+function pivotAxis(shelf: 'row' | 'column', dimensions: BIDimension[]): BIPivotAxis | null {+ if (dimensions.length === 0) {+ return null+ }++ return {+ alias: dimensions.length === 1 ? dimensions[0].alias : `bi_${shelf}s`,+ expression:+ dimensions.length === 1+ ? fieldExpression(dimensions[0].field)+ : `toJSONString(tuple(${dimensions.map(({ field }) => fieldExpression(field)).join(', ')}))`,+ label: dimensions.map(({ field }) => field.name || field.expression).join(' / '),+ }+}+function aggregationExpression(value: BIValue): string | null {if (value.aggregation === 'custom') {return value.customExpression?.trim() || null@@ -429,10 +475,22 @@ export function buildBIQuery(config: BIConfig): BIQueryBuildResult | null {return null}- const dimensions = [...config.rows, ...config.columns].filter(- (field) => field.expression.trim() || field.name.trim()- )- const dimensionExpressions = dimensions.map(fieldExpression)+ const rowDimensions = config.rows+ .map((field, index) => ({ alias: dimensionAlias('row', field, index), field }))+ .filter(({ field }) => field.expression.trim() || field.name.trim())+ const columnDimensions = config.columns+ .map((field, index) => ({ alias: dimensionAlias('column', field, index), field }))+ .filter(({ field }) => field.expression.trim() || field.name.trim())+ const dimensions = [...rowDimensions, ...columnDimensions]+ const dimensionExpressions = dimensions.map(({ field }) => fieldExpression(field))+ const isPivotTable = config.chartType === ChartDisplayType.TwoDimensionalHeatmap+ const pivotRowAxis = isPivotTable ? pivotAxis('row', rowDimensions) : null+ const pivotColumnAxis = isPivotTable ? pivotAxis('column', columnDimensions) : null+ const dimensionSelectExpressions = isPivotTable+ ? [pivotRowAxis, pivotColumnAxis]+ .filter((axis): axis is BIPivotAxis => axis !== null)+ .map(({ alias, expression }) => `${expression} AS ${alias}`)+ : dimensionExpressionsconst configuredValues = config.values.map((value) => ({ value, expression: aggregationExpression(value) })).filter(@@ -440,12 +498,12 @@ export function buildBIQuery(config: BIConfig): BIQueryBuildResult | null {)const valueExpressions =configuredValues.length > 0- ? configuredValues.map(({ value, expression }, index) => {- const alias = `${value.aggregation}_${sanitizeAlias(value.field.name)}${index > 0 ? `_${index + 1}` : ''}`- return `${expression} AS ${escapePropertyAsHogQLIdentifier(alias)}`- })+ ? configuredValues.map(+ ({ value, expression }, index) =>+ `${expression} AS ${escapePropertyAsHogQLIdentifier(aggregationAlias(value, index))}`+ ): ['count(*) AS count']- const selectExpressions = [...dimensionExpressions, ...valueExpressions]+ const selectExpressions = [...dimensionSelectExpressions, ...valueExpressions]const filters = config.filters.filter((filter) =>@@ -467,10 +525,22 @@ export function buildBIQuery(config: BIConfig): BIQueryBuildResult | null {queryParts.push(`GROUP BY\n ${dimensionExpressions.join(',\n ')}`)}- queryParts.push(`LIMIT ${config.limit}`)+ queryParts.push(`LIMIT ${normalizeBIConfig(config).limit}`)const query = queryParts.join('\n')+ const pivotTableSettings = isPivotTable+ ? {+ heatmap: {+ xAxisColumn: pivotColumnAxis?.alias,+ yAxisColumn: pivotRowAxis?.alias,+ valueColumn: configuredValues[0] ? aggregationAlias(configuredValues[0].value, 0) : 'count',+ xAxisLabel: pivotColumnAxis?.label ?? 'Columns',+ yAxisLabel: pivotRowAxis?.label ?? 'Rows',+ },+ }+ : undefined+return {query,node: {@@ -481,6 +551,7 @@ export function buildBIQuery(config: BIConfig): BIQueryBuildResult | null {connectionId: config.source.connectionId,},display: config.chartType,+ ...(pivotTableSettings ? { chartSettings: pivotTableSettings } : {}),},}}diff --git a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.tsindex 2baa0b03e961..72b499ff0c93 100644--- a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts+++ b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts@@ -1716,28 +1716,34 @@ describe('sqlEditorLogic', () => {logic.mount()const biLogic = biEditorLogic({ tabId: TAB_ID })biLogic.mount()+ const persistedConfig: BIConfig = {+ ...config,+ chartType: ChartDisplayType.TwoDimensionalHeatmap,+ limit: 50000,+ }+ const restoredConfig: BIConfig = { ...persistedConfig, limit: 1000 }router.actions.push(urls.sqlEditor(), undefined, {q: "SELECT event, count(*) FROM events WHERE event = 'signup' GROUP BY event",mode: BIEditorView.BI,- bi: config,+ bi: persistedConfig,})await expectLogic(logic).toDispatchActions(['createTab', 'updateTab']).toMatchValues({activeTab: partial({- biEditorState: { editorView: BIEditorView.BI, config },+ biEditorState: { editorView: BIEditorView.BI, config: restoredConfig },}),})- await expectLogic(biLogic).toMatchValues({ editorView: BIEditorView.BI, config })+ await expectLogic(biLogic).toMatchValues({ editorView: BIEditorView.BI, config: restoredConfig })await expectLogic(biLogic, () => biLogic.actions.setFilterValue(0, 'purchase')).toFinishAllListeners()expect(router.values.hashParams.mode).toEqual(BIEditorView.BI)expect(router.values.hashParams.bi).toEqual({- ...config,- filters: [{ ...config.filters[0], value: 'purchase' }],+ ...restoredConfig,+ filters: [{ ...restoredConfig.filters[0], value: 'purchase' }],})biLogic.unmount()@@ -1776,6 +1782,43 @@ describe('sqlEditorLogic', () => {biLogic.unmount()})+ it('regenerates the query and URL when the result limit changes', async () => {+ logic = sqlEditorLogic({+ tabId: TAB_ID,+ monaco: createMockMonaco(),+ editor: createMockEditor(),+ })+ logic.mount()+ const biLogic = biEditorLogic({ tabId: TAB_ID })+ biLogic.mount()++ router.actions.push(urls.sqlEditor(), undefined, {+ q: 'SELECT event, count(*) FROM events GROUP BY event LIMIT 1000',+ mode: BIEditorView.BI,+ bi: config,+ })+ await expectLogic(logic).toDispatchActions(['createTab', 'updateTab'])++ await expectLogic(biLogic, () => biLogic.actions.setLimit(50000)).toFinishAllListeners()++ expect(logic.values.queryInput).toContain('LIMIT 50000')+ expect(router.values.hashParams.bi).toEqual({ ...config, limit: 50000 })++ await expectLogic(biLogic, () =>+ biLogic.actions.setChartType(ChartDisplayType.TwoDimensionalHeatmap)+ ).toFinishAllListeners()++ expect(biLogic.values.config.limit).toBe(1000)+ expect(logic.values.queryInput).toContain('LIMIT 1000')+ expect(router.values.hashParams.bi).toEqual({+ ...config,+ chartType: ChartDisplayType.TwoDimensionalHeatmap,+ limit: 1000,+ })++ biLogic.unmount()+ })+it('clears incompatible fields and opens persisted blank shelf fields for editing', async () => {logic = sqlEditorLogic({tabId: TAB_ID,