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.

chore(insights): remove the sql insight date filter notice (#87764)

Thomas Obermüller507f13ecc15a
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index a061de2b95d6..4c8771fcea41 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -495,7 +495,6 @@ export const FEATURE_FLAGS = {
SQL_EDITOR_BI_MODE: 'sql-editor-bi-mode', // owner: @mariusandra #team-data-tools
SQL_EDITOR_LAZY_SCHEMA: 'sql-editor-lazy-schema', // owner: @mariusandra #team-data-tools
SQL_EDITOR_VIM_MODE: 'sql-editor-vim-mode', // owner: @arthurdedeus
- SQL_INSIGHT_DATE_FILTER_NOTICE: 'sql-insight-date-filter-notice', // owner: #team-product-analytics, gates the notice on SQL insights affected by the date filter resolution fix
SSE_DASHBOARDS: 'sse-dashboards', // owner: @aspicer #team-analytics-platform
STREAMLIT_APPS: 'streamlit-apps', // owner: @sakce
SUBSCRIPTION_AI_PROMPT: 'ai-subscriptions', // owner: #team-analytics-platform, gates AI prompt-based subscriptions
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/SqlInsightDateFilterNotice.test.ts b/frontend/src/queries/nodes/DataVisualization/Components/SqlInsightDateFilterNotice.test.ts
deleted file mode 100644
index 3291f5b787a1..000000000000
--- a/frontend/src/queries/nodes/DataVisualization/Components/SqlInsightDateFilterNotice.test.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import { DateRange, HogQLQuery, NodeKind } from '~/queries/schema/schema-general'
-
-import { isAffectedByDateFilterResolutionChange } from './SqlInsightDateFilterNotice'
-
-function hogQLQuery(query: string, filters?: HogQLQuery['filters']): HogQLQuery {
- return { kind: NodeKind.HogQLQuery, query, filters }
-}
-
-const FILTERED_SQL = 'SELECT count() FROM demo WHERE ts >= {filters.dateRange.from} AND ts <= {filters.dateRange.to}'
-
-describe('isAffectedByDateFilterResolutionChange', () => {
- it.each<[string, DateRange, boolean]>([
- // affected: relative day-or-coarser date_from snaps to midnight
- ['relative month start', { date_from: 'mStart', date_to: null }, true],
- ['relative days with explicit datetime end', { date_from: '-7d', date_to: '2026-07-24T23:59:59' }, true],
- ['relative week start', { date_from: 'wStart', date_to: null }, true],
- // affected: open-ended ranges gain an end-of-today upper bound
- ['absolute start with no end', { date_from: '2026-07-01', date_to: null }, true],
- // affected: date-only or relative date_to now covers the whole day
- ['date-only end', { date_from: '2026-07-01', date_to: '2026-07-24' }, true],
- ['relative end', { date_from: '2026-07-01', date_to: '-3d' }, true],
- // unaffected: "all" and sub-day rolling windows are exempt from the fix
- ['all time with no end', { date_from: 'all', date_to: null }, false],
- ['rolling hour window', { date_from: '-1h', date_to: null }, false],
- ['rolling minute window', { date_from: '-30M', date_to: null }, false],
- // unaffected: explicit datetimes are used verbatim
- ['absolute start and datetime end', { date_from: '2026-07-01', date_to: '2026-07-24T23:59:59' }, false],
- // unaffected: no date filter in use
- ['empty date range', { date_from: null, date_to: null }, false],
- // explicitDate disables the end-of-day snapping of date_to only; date_from still snaps
- [
- 'explicit date with date-only end',
- { date_from: '2026-07-01', date_to: '2026-07-24', explicitDate: true },
- false,
- ],
- ['explicit date with no end', { date_from: '2026-07-01', date_to: null, explicitDate: true }, true],
- ['explicit date with relative preset', { date_from: '-1mStart', date_to: '-1mEnd', explicitDate: true }, true],
- ])('%s -> %s', (_name, dateRange, expected) => {
- expect(isAffectedByDateFilterResolutionChange(hogQLQuery(FILTERED_SQL, { dateRange }))).toBe(expected)
- })
-
- it('is unaffected without a filters placeholder or date range', () => {
- expect(
- isAffectedByDateFilterResolutionChange(
- hogQLQuery('SELECT count() FROM demo', { dateRange: { date_from: 'mStart' } })
- )
- ).toBe(false)
- expect(isAffectedByDateFilterResolutionChange(hogQLQuery(FILTERED_SQL))).toBe(false)
- })
-})
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/SqlInsightDateFilterNotice.tsx b/frontend/src/queries/nodes/DataVisualization/Components/SqlInsightDateFilterNotice.tsx
deleted file mode 100644
index 5c58e230fa0c..000000000000
--- a/frontend/src/queries/nodes/DataVisualization/Components/SqlInsightDateFilterNotice.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { useValues } from 'kea'
-
-import { LemonBanner } from '@posthog/lemon-ui'
-
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-
-import { HogQLQuery } from '~/queries/schema/schema-general'
-
-// Relative ranges in day-or-coarser units ("mStart", "-7d") now snap to the start of the day,
-// and open-ended ranges gain an end-of-today upper bound. Sub-day rolling windows ("-1h")
-// were exempted from both, so they are not part of the affected shape.
-const DAY_OR_COARSER_RELATIVE_REGEX = /^-?\d*[dwmqy](Start|End)?$/
-const SUB_DAY_RELATIVE_REGEX = /^-?\d*[hMs](Start|End)?$/
-const DATE_ONLY_REGEX = /^\d{4}-\d{1,2}-\d{1,2}$/
-
-/** Whether the SQL date filter resolution fix can produce different results for this query.
- * Mirrors the affected shapes of ReplaceFilters in posthog/hogql/filters.py. */
-export function isAffectedByDateFilterResolutionChange(source: HogQLQuery): boolean {
- if (!source.query?.includes('{filters')) {
- return false
- }
- const dateRange = source.filters?.dateRange
- if (!dateRange || (dateRange.date_from == null && dateRange.date_to == null)) {
- return false
- }
- // "all" stays fully unbounded (no lower bound and no end-of-today cap), so it is unaffected
- const openEndedWithBoundedStart =
- dateRange.date_to == null &&
- dateRange.date_from != null &&
- dateRange.date_from !== 'all' &&
- !SUB_DAY_RELATIVE_REGEX.test(dateRange.date_from)
- const snappedDateFrom = dateRange.date_from != null && DAY_OR_COARSER_RELATIVE_REGEX.test(dateRange.date_from)
- if (dateRange.explicitDate) {
- // explicitDate disables end-of-day snapping of date_to only; date_from still snaps to midnight
- return openEndedWithBoundedStart || snappedDateFrom
- }
- return (
- openEndedWithBoundedStart ||
- snappedDateFrom ||
- (dateRange.date_to != null &&
- (DATE_ONLY_REGEX.test(dateRange.date_to) || DAY_OR_COARSER_RELATIVE_REGEX.test(dateRange.date_to)))
- )
-}
-
-export function SqlInsightDateFilterNotice({ source }: { source: HogQLQuery }): JSX.Element | null {
- const { featureFlags } = useValues(featureFlagLogic)
-
- if (
- !featureFlags[FEATURE_FLAGS.SQL_INSIGHT_DATE_FILTER_NOTICE] ||
- !isAffectedByDateFilterResolutionChange(source)
- ) {
- return null
- }
-
- return (
- <LemonBanner type="info" dismissKey="sql-insight-date-filter-notice">
- Date filters on SQL insights now match other insights: relative ranges start at midnight, and open-ended
- ranges include all of today but nothing after. Results may differ slightly from before.
- </LemonBanner>
- )
-}
diff --git a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
index 8b41d747ce45..1b932ec36ee9 100644
--- a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
@@ -40,7 +40,6 @@ import { SqlScatterGraph } from './Components/Charts/SqlScatterGraph'
import { TwoDimensionalHeatmap } from './Components/Heatmap/TwoDimensionalHeatmap'
import { seriesBreakdownLogic } from './Components/seriesBreakdownLogic'
import { SideBar } from './Components/SideBar'
-import { SqlInsightDateFilterNotice } from './Components/SqlInsightDateFilterNotice'
import { Table } from './Components/Table'
import { TableDisplay } from './Components/TableDisplay'
import { AddVariableButton } from './Components/Variables/AddVariableButton'
@@ -376,8 +375,6 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
</>
)}
- <SqlInsightDateFilterNotice source={query.source} />
-
{!props.embedded && <VariablesForInsight />}
<div className="flex flex-1 flex-row gap-4">