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(frontend): move the hogql template tag to lib/utils (#126848)

Paul D'Ambra6562a21f793f
diff --git a/frontend/bin/layer-baseline.txt b/frontend/bin/layer-baseline.txt
index 7194f3f69b36..fc17b6f87246 100644
--- a/frontend/bin/layer-baseline.txt
+++ b/frontend/bin/layer-baseline.txt
@@ -110,8 +110,6 @@ frontend/src/lib/components/AnnotationsOverlay/AnnotationsOverlay.tsx -> product
frontend/src/lib/components/AnnotationsOverlay/AnnotationsOverlay.tsx -> products/annotations/frontend/logics/annotationModalLogic.ts
frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts -> frontend/src/scenes/insights/insightLogic.tsx
frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts -> frontend/src/scenes/insights/insightVizDataLogic.ts
-frontend/src/lib/components/AppMetrics/appMetricsLogic.ts -> frontend/src/queries/utils.ts
-frontend/src/lib/components/AuthorizedUrlList/authorizedUrlListLogic.ts -> frontend/src/queries/utils.ts
frontend/src/lib/components/Cards/InsightCard/DashboardInsightDisplayOptions.tsx -> products/product_analytics/frontend/insights/editor/InsightDisplayOptionsPanel.tsx
frontend/src/lib/components/Cards/InsightCard/DashboardSqlDisplayOptions.tsx -> frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx
frontend/src/lib/components/Cards/InsightCard/DashboardSqlDisplayOptions.tsx -> frontend/src/queries/nodes/DataVisualization/Components/TableDisplay.tsx
@@ -201,7 +199,6 @@ frontend/src/lib/components/HedgehogMode/HedgehogMode.tsx -> frontend/src/toolba
frontend/src/lib/components/HedgehogMode/hedgehogModeLogic.ts -> frontend/src/toolbar/shared/toolbarConfigLogic.ts
frontend/src/lib/components/HedgehogMode/hedgehogModeLogic.ts -> frontend/src/toolbar/shared/toolbarFetch.ts
frontend/src/lib/components/HighlightedJSONViewer.tsx -> products/ai_observability/frontend/ConversationDisplay/HighlightedContentWrapper.tsx
-frontend/src/lib/components/HogQLDropdown/HogQLDropdown.tsx -> frontend/src/queries/utils.ts
frontend/src/lib/components/HogQLEditor/HogQLEditor.tsx -> frontend/src/queries/utils.ts
frontend/src/lib/components/IngestionControls/TriggerMatchChoice.tsx -> frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/AndOrFilterSelect.tsx
frontend/src/lib/components/IngestionControls/TriggerMatchChoice.tsx -> frontend/src/scenes/settings/environment/SessionRecordingSettings.tsx
@@ -223,8 +220,6 @@ frontend/src/lib/components/IntervalFilter/IntervalFilter.tsx -> frontend/src/sc
frontend/src/lib/components/IntervalFilter/IntervalFilter.tsx -> frontend/src/scenes/insights/insightVizDataLogic.ts
frontend/src/lib/components/JSSnippet.tsx -> docs/onboarding/product-analytics/index.ts
frontend/src/lib/components/JSSnippet.tsx -> frontend/src/scenes/settings/environment/proxyLogic.ts
-frontend/src/lib/components/LiveUserCount/liveUserCountLogic.ts -> frontend/src/queries/utils.ts
-frontend/src/lib/components/Metalytics/metalyticsLogic.ts -> frontend/src/queries/utils.ts
frontend/src/lib/components/NotFound/index.tsx -> frontend/src/scenes/activity/explore/defaults.ts
frontend/src/lib/components/NotFound/index.tsx -> frontend/src/scenes/notebooks/Nodes/NotebookNodeContext.ts
frontend/src/lib/components/PathCleanFilters/PathRegexModal.tsx -> frontend/src/scenes/session-recordings/components/AiRegexHelper/AiRegexHelper.tsx
@@ -245,7 +240,6 @@ frontend/src/lib/components/PropertyFilters/utils.ts -> frontend/src/queries/nod
frontend/src/lib/components/PropertyKeyInfo.tsx -> frontend/src/scenes/surveys/surveyQuestionLabelsLogic.ts
frontend/src/lib/components/QuickFilters/quickFiltersLogic.ts -> frontend/src/exporter/exporterViewLogic.ts
frontend/src/lib/components/ResultMenu/ResultMenu.tsx -> frontend/src/scenes/insights/utils.tsx
-frontend/src/lib/components/ReverseProxyChecker/reverseProxyCheckerLogic.ts -> frontend/src/queries/utils.ts
frontend/src/lib/components/SaveToCohortModalContent/saveToCohortModalContentLogic.ts -> frontend/src/scenes/cohorts/cohortEditLogic.ts
frontend/src/lib/components/SaveToCohortModalContent/saveToCohortModalContentLogic.ts -> frontend/src/scenes/cohorts/cohortSavedToast.ts
frontend/src/lib/components/Scenes/InsightOrDashboard/SceneAddToNotebookDropdownMenu.tsx -> frontend/src/scenes/notebooks/types.ts
@@ -267,7 +261,6 @@ frontend/src/lib/components/SessionTimeline/timeline/items/custom.tsx -> product
frontend/src/lib/components/SessionTimeline/timeline/items/eventDetails.tsx -> frontend/src/scenes/sessions/components/SessionEventDetails.tsx
frontend/src/lib/components/SessionTimeline/timeline/items/exceptionSteps.tsx -> products/error_tracking/frontend/components/RuntimeIcon.tsx
frontend/src/lib/components/SessionTimeline/timeline/items/exceptions.tsx -> products/error_tracking/frontend/components/RuntimeIcon.tsx
-frontend/src/lib/components/SessionTimeline/timeline/items/logs.tsx -> frontend/src/queries/utils.ts
frontend/src/lib/components/SessionTimeline/timeline/items/logs.tsx -> products/error_tracking/frontend/components/RuntimeIcon.tsx
frontend/src/lib/components/SessionTimeline/timeline/items/page.tsx -> products/error_tracking/frontend/components/RuntimeIcon.tsx
frontend/src/lib/components/Sharing/SharingModal.tsx -> frontend/src/queries/nodes/InsightQuery/defaults.ts
@@ -282,7 +275,6 @@ frontend/src/lib/components/SurveyResponseDisplay/SurveyResponseDisplay.tsx -> f
frontend/src/lib/components/SurveyResponseDisplay/SurveyResponseDisplay.tsx -> frontend/src/scenes/surveys/utils.ts
frontend/src/lib/components/SurveyResponseDisplay/SurveyResponseDisplay.tsx -> products/persons/frontend/components/PersonDisplay.tsx
frontend/src/lib/components/TablePreview/databaseTablePreviewLogic.ts -> frontend/src/queries/query.ts
-frontend/src/lib/components/TablePreview/databaseTablePreviewLogic.ts -> frontend/src/queries/utils.ts
frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx -> frontend/src/scenes/data-management/events/DefinitionHeader.tsx
frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx -> frontend/src/scenes/data-warehouse/settings/dataWarehouseSettingsSceneLogic.ts
frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx -> frontend/src/scenes/feature-flags/constants.tsx
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 68d37e942d8d..a6048fa6ab84 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -19,6 +19,7 @@ import { ApiRequestTiming, ApiRequestTimingRecorder } from 'lib/apiRequestTiming
import { ActivityLogProps } from 'lib/components/ActivityLog/ActivityLog'
import { ActivityLogItem } from 'lib/components/ActivityLog/humanizeActivity'
import { apiStatusLogic, awaitReauthentication, isUserActionInProgress } from 'lib/logic/apiStatusLogic'
+import { HogQLQueryString } from 'lib/utils/hogql'
import { getBackendHost, getStoredSession, isOAuthMode, refreshAccessToken } from 'lib/utils/oauthClient'
import { objectClean } from 'lib/utils/objects'
import { toParams } from 'lib/utils/url'
@@ -69,7 +70,7 @@ import {
SpanTreeNode,
TileFilters,
} from '~/queries/schema/schema-general'
-import { HogQLQueryString, setLatestVersionsOnQuery } from '~/queries/utils'
+import { setLatestVersionsOnQuery } from '~/queries/utils'
import {
ActionType,
ActivityScope,
diff --git a/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts b/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts
index 48ba72b2e863..4887130e0435 100644
--- a/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts
+++ b/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts
@@ -18,11 +18,10 @@ import { subscriptions } from 'kea-subscriptions'
import api from 'lib/api'
import { Dayjs, dayjs } from 'lib/dayjs'
import { dateStringToDayJs } from 'lib/utils/dateFilters'
+import { HogQLQueryString, hogql } from 'lib/utils/hogql'
import { objectsEqual } from 'lib/utils/objects'
import { teamLogic } from 'scenes/teamLogic'
-import { HogQLQueryString, hogql } from '~/queries/utils'
-
import type { TeamPublicType, TeamType } from '../../../types'
const DEFAULT_INTERVAL = 'day'
diff --git a/frontend/src/lib/components/AuthorizedUrlList/authorizedUrlListLogic.ts b/frontend/src/lib/components/AuthorizedUrlList/authorizedUrlListLogic.ts
index 664cb33b7a5d..9293f6b7078c 100644
--- a/frontend/src/lib/components/AuthorizedUrlList/authorizedUrlListLogic.ts
+++ b/frontend/src/lib/components/AuthorizedUrlList/authorizedUrlListLogic.ts
@@ -26,6 +26,7 @@ import {
} from 'lib/components/AuthorizedUrlList/authorizedUrlMatching'
import { SetupTaskId, globalSetupLogic } from 'lib/components/ProductSetup'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
+import { hogql } from 'lib/utils/hogql'
import { addProductIntent } from 'lib/utils/product-intents'
import { isDomain, isURL } from 'lib/utils/url'
import { sceneLogic } from 'scenes/sceneLogic'
@@ -34,7 +35,6 @@ import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { ExperimentIdType, ToolbarParams, ToolbarUserIntent } from '~/types'
import type { TeamPublicType, TeamType, UserType } from '../../../types'
diff --git a/frontend/src/lib/components/HogQLDropdown/HogQLDropdown.tsx b/frontend/src/lib/components/HogQLDropdown/HogQLDropdown.tsx
index 210b232450e6..0661cba31b7d 100644
--- a/frontend/src/lib/components/HogQLDropdown/HogQLDropdown.tsx
+++ b/frontend/src/lib/components/HogQLDropdown/HogQLDropdown.tsx
@@ -4,8 +4,9 @@ import { useState } from 'react'
import { LemonButton, LemonDropdown } from '@posthog/lemon-ui'
+import { escapeDottedHogQLIdentifier } from 'lib/utils/hogql'
+
import { NodeKind } from '~/queries/schema/schema-general'
-import { escapeDottedHogQLIdentifier } from '~/queries/utils'
import { HogQLEditor } from '../HogQLEditor/HogQLEditor'
diff --git a/frontend/src/lib/components/LiveUserCount/liveCountCache.ts b/frontend/src/lib/components/LiveUserCount/liveCountCache.ts
index 8f97727c4ae0..bcc5faddacdc 100644
--- a/frontend/src/lib/components/LiveUserCount/liveCountCache.ts
+++ b/frontend/src/lib/components/LiveUserCount/liveCountCache.ts
@@ -1,7 +1,7 @@
import api from 'lib/api'
+import { HogQLQueryString } from 'lib/utils/hogql'
import { QueryLogTags } from '~/queries/schema/schema-general'
-import { HogQLQueryString } from '~/queries/utils'
export const LIVE_COUNT_REFRESH_MS = 30000
// pinned: localStorage key prefix, renaming it drops every user's cached counts
diff --git a/frontend/src/lib/components/LiveUserCount/liveUserCountLogic.ts b/frontend/src/lib/components/LiveUserCount/liveUserCountLogic.ts
index 9a80cda65da6..5050ea188f6c 100644
--- a/frontend/src/lib/components/LiveUserCount/liveUserCountLogic.ts
+++ b/frontend/src/lib/components/LiveUserCount/liveUserCountLogic.ts
@@ -3,10 +3,9 @@ import { MakeLogicType, actions, connect, events, kea, key, listeners, path, pro
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { liveEventsHostOrigin } from 'lib/utils/apiHost'
+import { hogql } from 'lib/utils/hogql'
import { teamLogic } from 'scenes/teamLogic'
-import { hogql } from '~/queries/utils'
-
import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'
import type { TeamPublicType, TeamType } from '../../../types'
import { LIVE_COUNT_REFRESH_MS, loadCachedLiveCount } from './liveCountCache'
diff --git a/frontend/src/lib/components/Metalytics/metalyticsLogic.ts b/frontend/src/lib/components/Metalytics/metalyticsLogic.ts
index a8023b57b296..d286947298b4 100644
--- a/frontend/src/lib/components/Metalytics/metalyticsLogic.ts
+++ b/frontend/src/lib/components/Metalytics/metalyticsLogic.ts
@@ -3,6 +3,7 @@ import { loaders } from 'kea-loaders'
import { subscriptions } from 'kea-subscriptions'
import api from 'lib/api'
+import { hogql } from 'lib/utils/hogql'
import { sceneLogic } from 'scenes/sceneLogic'
import { teamLogic } from 'scenes/teamLogic'
@@ -11,7 +12,6 @@ import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePane
import { SidePanelSceneContext } from '~/layout/navigation-3000/sidepanel/types'
import { sceneLayoutLogic } from '~/layout/scenes/sceneLayoutLogic'
import { membersLogic } from '~/models/membersLogic'
-import { hogql } from '~/queries/utils'
import { ActivityScope, SidePanelTab } from '~/types'
import type { OrganizationMemberType } from '../../../types'
diff --git a/frontend/src/lib/components/ReverseProxyChecker/reverseProxyCheckerLogic.ts b/frontend/src/lib/components/ReverseProxyChecker/reverseProxyCheckerLogic.ts
index c10eea335f7e..703099926ba3 100644
--- a/frontend/src/lib/components/ReverseProxyChecker/reverseProxyCheckerLogic.ts
+++ b/frontend/src/lib/components/ReverseProxyChecker/reverseProxyCheckerLogic.ts
@@ -4,10 +4,9 @@ import posthog from 'posthog-js'
import api from 'lib/api'
import { SetupTaskId, globalSetupLogic } from 'lib/components/ProductSetup'
+import { hogql } from 'lib/utils/hogql'
import { sceneLogic } from 'scenes/sceneLogic'
-import { hogql } from '~/queries/utils'
-
const CHECK_INTERVAL_MS = 1000 * 60 * 10 // 10 minutes
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
diff --git a/frontend/src/lib/components/SessionTimeline/timeline/items/logs.tsx b/frontend/src/lib/components/SessionTimeline/timeline/items/logs.tsx
index 8f16c2b25bfa..38f720e5cdcf 100644
--- a/frontend/src/lib/components/SessionTimeline/timeline/items/logs.tsx
+++ b/frontend/src/lib/components/SessionTimeline/timeline/items/logs.tsx
@@ -3,8 +3,7 @@ import { IconLive } from '@posthog/icons'
import api from 'lib/api'
import { Dayjs, dayjs } from 'lib/dayjs'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
-
-import { hogql } from '~/queries/utils'
+import { hogql } from 'lib/utils/hogql'
import { RuntimeIcon } from 'products/error_tracking/frontend/components/RuntimeIcon'
diff --git a/frontend/src/lib/components/TablePreview/databaseTablePreviewLogic.ts b/frontend/src/lib/components/TablePreview/databaseTablePreviewLogic.ts
index 6793498352e9..bc5229ff1fbc 100644
--- a/frontend/src/lib/components/TablePreview/databaseTablePreviewLogic.ts
+++ b/frontend/src/lib/components/TablePreview/databaseTablePreviewLogic.ts
@@ -2,8 +2,9 @@ import { MakeLogicType, afterMount, kea, key, path, props, propsChanged } from '
import { loaders } from 'kea-loaders'
import posthog from 'posthog-js'
+import { hogql } from 'lib/utils/hogql'
+
import { hogqlQuery } from '~/queries/query'
-import { hogql } from '~/queries/utils'
import type { TablePreviewExpressionColumn } from './types'
diff --git a/frontend/src/lib/utils/hogql.test.ts b/frontend/src/lib/utils/hogql.test.ts
new file mode 100644
index 000000000000..ad3648363d8a
--- /dev/null
+++ b/frontend/src/lib/utils/hogql.test.ts
@@ -0,0 +1,145 @@
+import { MOCK_TEAM_ID } from 'lib/api.mock'
+
+import { dayjs } from 'lib/dayjs'
+import { getAppContext } from 'lib/utils/getAppContext'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { initKeaTests } from '~/test/init'
+import { AppContext, TeamType } from '~/types'
+
+import { escapeDottedHogQLIdentifier, escapeHogQLString, escapePropertyAsHogQLIdentifier, hogql } from './hogql'
+
+window.POSTHOG_APP_CONTEXT = { current_team: { id: MOCK_TEAM_ID } } as unknown as AppContext
+
+describe('hogql tag', () => {
+ // In beforeEach (not describe scope): mounting at collection time fires the preflight
+ // load before the MSW harness's beforeAll has installed its fetch stub
+ beforeEach(() => {
+ initKeaTests()
+ teamLogic.mount()
+ })
+
+ it('properly returns query with no substitutions', () => {
+ expect(hogql`SELECT * FROM events`).toEqual('SELECT * FROM events')
+ })
+
+ it('properly returns query with simple identifier substition', () => {
+ expect(hogql`SELECT * FROM ${hogql.identifier('events')}`).toEqual('SELECT * FROM events')
+ })
+
+ it('properly returns query with escaped identifier substition', () => {
+ expect(hogql`SELECT properties.${hogql.identifier('odd property')} FROM events`).toEqual(
+ 'SELECT properties."odd property" FROM events'
+ )
+ })
+
+ it('properly returns query with string and number substitutions', () => {
+ expect(hogql`SELECT * FROM events WHERE properties.foo = ${'bar'} AND properties.baz = ${3}`).toEqual(
+ "SELECT * FROM events WHERE properties.foo = 'bar' AND properties.baz = 3"
+ )
+ })
+
+ it('properly returns query with string array substitution', () => {
+ expect(hogql`SELECT * FROM events WHERE properties.foo IN ${['bar', 'baz']}`).toEqual(
+ "SELECT * FROM events WHERE properties.foo IN ['bar', 'baz']"
+ )
+ })
+
+ it('properly returns query with date substitution in UTC', () => {
+ teamLogic.actions.loadCurrentTeamSuccess({ id: MOCK_TEAM_ID, timezone: 'UTC' } as TeamType)
+ expect(hogql`SELECT * FROM events WHERE timestamp > ${dayjs('2023-04-04T04:04:00Z')}`).toEqual(
+ "SELECT * FROM events WHERE timestamp > '2023-04-04 04:04:00'"
+ )
+ })
+
+ it('properly returns query with date substitution in non-UTC', () => {
+ const context = getAppContext()
+ let oldTimezone = context?.current_team?.timezone || 'UTC'
+ if (context?.current_team) {
+ context.current_team.timezone = 'Europe/Moscow'
+ }
+ teamLogic.actions.loadCurrentTeamSuccess({ id: MOCK_TEAM_ID, timezone: 'Europe/Moscow' } as TeamType)
+ expect(hogql`SELECT * FROM events WHERE timestamp > ${dayjs('2023-04-04T04:04:00Z')}`).toEqual(
+ "SELECT * FROM events WHERE timestamp > '2023-04-04 07:04:00'" // Offset by 3 hours
+ )
+ if (context?.current_team) {
+ context.current_team.timezone = oldTimezone
+ }
+ })
+
+ it('properly escapes single quotes in string values', () => {
+ expect(hogql`SELECT * FROM events WHERE properties.name = ${"O'Reilly"}`).toEqual(
+ "SELECT * FROM events WHERE properties.name = 'O\\'Reilly'"
+ )
+ })
+
+ it('properly escapes backslashes in string values', () => {
+ expect(hogql`SELECT * FROM events WHERE properties.path = ${'C:\\Users\\test'}`).toEqual(
+ "SELECT * FROM events WHERE properties.path = 'C:\\\\Users\\\\test'"
+ )
+ })
+})
+
+describe('escapeHogQLString', () => {
+ it.each([
+ ['simple', "'simple'"],
+ ["O'Reilly", "'O\\'Reilly'"],
+ ["'; DROP TABLE users; --", "'\\'; DROP TABLE users; --'"],
+ ['C:\\Users\\test', "'C:\\\\Users\\\\test'"],
+ ['line1\nline2', "'line1\\nline2'"],
+ ['tab\there', "'tab\\there'"],
+ ['carriage\rreturn', "'carriage\\rreturn'"],
+ ['', "''"],
+ ["multiple'quotes'here", "'multiple\\'quotes\\'here'"],
+ ['back\\slash', "'back\\\\slash'"],
+ ])('escapes %s to %s', (input, expected) => {
+ expect(escapeHogQLString(input)).toEqual(expected)
+ })
+})
+
+describe('escapePropertyAsHogQLIdentifier', () => {
+ it('leaves simple identifiers unquoted', () => {
+ expect(escapePropertyAsHogQLIdentifier('browser')).toEqual('browser')
+ expect(escapePropertyAsHogQLIdentifier('$browser')).toEqual('$browser')
+ })
+
+ it('double-quotes identifiers with special characters but no double quote', () => {
+ expect(escapePropertyAsHogQLIdentifier('order items')).toEqual('"order items"')
+ })
+
+ it('backtick-wraps identifiers containing a double quote', () => {
+ expect(escapePropertyAsHogQLIdentifier('a"b')).toEqual('`a"b`')
+ })
+
+ it('doubles inner backticks when an identifier has both a double quote and a backtick', () => {
+ // Backslash-escaping (`a"b\`c`) would be rejected by the HogQL parser; doubling round-trips.
+ expect(escapePropertyAsHogQLIdentifier('a"b`c')).toEqual('`a"b``c`')
+ })
+
+ it('escapes backslashes so they survive the parser instead of forming an escape sequence', () => {
+ expect(escapePropertyAsHogQLIdentifier('a\\b')).toEqual('"a\\\\b"')
+ expect(escapePropertyAsHogQLIdentifier('end\\')).toEqual('"end\\\\"')
+ // A backslash alongside a double quote takes the backtick branch and still escapes both.
+ expect(escapePropertyAsHogQLIdentifier('a"\\b')).toEqual('`a"\\\\b`')
+ // A backslash immediately before an inner backtick (which forces the backtick branch).
+ expect(escapePropertyAsHogQLIdentifier('a"b\\`c')).toEqual('`a"b\\\\``c`')
+ })
+
+ it('escapes control characters instead of emitting them raw', () => {
+ expect(escapePropertyAsHogQLIdentifier('a\tb')).toEqual('"a\\tb"')
+ expect(escapePropertyAsHogQLIdentifier('a\nb')).toEqual('"a\\nb"')
+ expect(escapePropertyAsHogQLIdentifier('a\bb')).toEqual('"a\\bb"')
+ // An embedded double quote forces the backtick branch; the control char is still escaped.
+ expect(escapePropertyAsHogQLIdentifier('a"\tb')).toEqual('`a"\\tb`')
+ })
+})
+
+describe('escapeDottedHogQLIdentifier', () => {
+ it('leaves simple dotted identifiers unquoted', () => {
+ expect(escapeDottedHogQLIdentifier('demo.orders')).toEqual('demo.orders')
+ })
+
+ it('quotes each dotted segment independently when needed', () => {
+ expect(escapeDottedHogQLIdentifier('demo.order items')).toEqual('demo."order items"')
+ })
+})
diff --git a/frontend/src/lib/utils/hogql.ts b/frontend/src/lib/utils/hogql.ts
new file mode 100644
index 000000000000..2431e6a9aec7
--- /dev/null
+++ b/frontend/src/lib/utils/hogql.ts
@@ -0,0 +1,147 @@
+import { dayjs } from 'lib/dayjs'
+import { getAppContext } from 'lib/utils/getAppContext'
+
+export function isQuoted(identifier: string): boolean {
+ return (
+ (identifier.startsWith('"') && identifier.endsWith('"')) ||
+ (identifier.startsWith('`') && identifier.endsWith('`'))
+ )
+}
+
+// Mirrors escape_chars_map in posthog/hogql/escape_sql.py: backslash and control chars must be escaped so a quoted identifier round-trips losslessly through the HogQL parser.
+const HOGQL_IDENTIFIER_ESCAPE_MAP: Record<string, string> = {
+ '\b': '\\b',
+ '\f': '\\f',
+ '\r': '\\r',
+ '\n': '\\n',
+ '\t': '\\t',
+ '\0': '\\0',
+ '\x07': '\\a',
+ '\v': '\\v',
+ '\\': '\\\\',
+}
+
+/** Make sure the property key is wrapped in quotes if it contains any special characters. */
+export function escapePropertyAsHogQLIdentifier(identifier: string): string {
+ if (identifier.match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) {
+ // Same regex as in the backend escape_hogql_identifier
+ return identifier // This identifier is simple
+ }
+ if (isQuoted(identifier)) {
+ return identifier // This identifier is already quoted
+ }
+ return escapeRawPropertyAsHogQLIdentifier(identifier)
+}
+
+export function escapeRawPropertyAsHogQLIdentifier(identifier: string): string {
+ if (identifier.match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) {
+ return identifier
+ }
+ // Escape backslashes and control chars, then wrap; double an inner backtick (the parser rejects a backslash-escaped delimiter). The double-quote path needs no quote escaping since it is only taken when the identifier has no `"`.
+ const escaped = Array.from(identifier, (c) => HOGQL_IDENTIFIER_ESCAPE_MAP[c] || c).join('')
+ return !identifier.includes('"') ? `"${escaped}"` : `\`${escaped.replaceAll('`', '``')}\``
+}
+
+/** Quote each segment of a dotted HogQL reference independently. */
+export function escapeDottedHogQLIdentifier(identifier: string): string {
+ if (isQuoted(identifier) || !identifier.includes('.')) {
+ return escapePropertyAsHogQLIdentifier(identifier)
+ }
+
+ return identifier
+ .split('.')
+ .map((segment) => escapePropertyAsHogQLIdentifier(segment))
+ .join('.')
+}
+
+declare const __hogqlBrand: unique symbol
+export type HogQLQueryString = string & { readonly [__hogqlBrand]: void }
+
+export interface HogQLIdentifier {
+ __hogql_identifier: true
+ identifier: string
+}
+
+function hogQLIdentifier(identifier: string): HogQLIdentifier {
+ return {
+ __hogql_identifier: true,
+ identifier,
+ }
+}
+
+function isHogQLIdentifier(value: any): value is HogQLIdentifier {
+ return !!value?.__hogql_identifier
+}
+
+export interface HogQLRaw {
+ __hogql_raw: true
+ raw: string
+}
+
+function hogQLRaw(raw: string): HogQLRaw {
+ return {
+ __hogql_raw: true,
+ raw,
+ }
+}
+
+function isHogQLRaw(value: any): value is HogQLRaw {
+ return !!value?.__hogql_raw
+}
+
+const ESCAPE_CHARS_MAP: Record<string, string> = {
+ '\b': '\\b',
+ '\f': '\\f',
+ '\r': '\\r',
+ '\n': '\\n',
+ '\t': '\\t',
+ '\0': '\\0',
+ '\x07': '\\a',
+ '\v': '\\v',
+ '\\': '\\\\',
+ "'": "\\'",
+}
+
+export function escapeHogQLString(value: string): string {
+ let escaped = ''
+ for (const char of value) {
+ escaped += ESCAPE_CHARS_MAP[char] ?? char
+ }
+ return `'${escaped}'`
+}
+
+function formatHogQLValue(value: any): string {
+ if (Array.isArray(value)) {
+ return `[${value.map(formatHogQLValue).join(', ')}]`
+ } else if (dayjs.isDayjs(value)) {
+ const timezone = getAppContext()?.current_team?.timezone || 'UTC'
+ return value.tz(timezone).format("'YYYY-MM-DD HH:mm:ss'")
+ } else if (isHogQLIdentifier(value)) {
+ return escapePropertyAsHogQLIdentifier(value.identifier)
+ } else if (isHogQLRaw(value)) {
+ return value.raw
+ } else if (typeof value === 'string') {
+ return escapeHogQLString(value)
+ } else if (typeof value === 'number') {
+ return String(value)
+ } else if (value === null) {
+ throw new Error(
+ `null cannot be interpolated for SQL. if a null check is needed, make 'IS NULL' part of your query`
+ )
+ } else {
+ throw new Error(`Unsupported interpolated value type: ${typeof value}`)
+ }
+}
+
+/**
+ * Template tag for HogQL formatting. Handles formatting of values for you.
+ * @example hogql`SELECT * FROM events WHERE properties.text = ${text} AND timestamp > ${dayjs()}`
+ */
+export function hogql(strings: TemplateStringsArray, ...values: any[]): HogQLQueryString {
+ return strings.reduce(
+ (acc, str, i) => acc + str + (i < strings.length - 1 ? formatHogQLValue(values[i]) : ''),
+ ''
+ ) as unknown as HogQLQueryString
+}
+hogql.identifier = hogQLIdentifier
+hogql.raw = hogQLRaw
diff --git a/frontend/src/queries/nodes/DataTable/defaultEventsQuery.ts b/frontend/src/queries/nodes/DataTable/defaultEventsQuery.ts
index ea8372766bf0..d57e32b82614 100644
--- a/frontend/src/queries/nodes/DataTable/defaultEventsQuery.ts
+++ b/frontend/src/queries/nodes/DataTable/defaultEventsQuery.ts
@@ -1,7 +1,7 @@
+import { escapePropertyAsHogQLIdentifier } from 'lib/utils/hogql'
import { getDefaultEventsSceneQuery } from 'scenes/activity/explore/defaults'
import { EventsQuery, NodeKind } from '~/queries/schema/schema-general'
-import { escapePropertyAsHogQLIdentifier } from '~/queries/utils'
import { TeamType } from '~/types'
/** Indicates HogQL usage if team.live_events_columns = [HOGQL_COLUMNS_KEY, ...] */
diff --git a/frontend/src/queries/query.ts b/frontend/src/queries/query.ts
index aa34e93490e8..e3a84fc1ce29 100644
--- a/frontend/src/queries/query.ts
+++ b/frontend/src/queries/query.ts
@@ -4,6 +4,7 @@ import { ApiRequestTiming, flattenRequestTiming } from 'lib/apiRequestTiming'
import posthog from 'lib/posthog-typed'
import { delay, retryWithBackoff } from 'lib/utils/async'
import { uuid } from 'lib/utils/dom'
+import { HogQLQueryString } from 'lib/utils/hogql'
import { isSharedView } from '~/exporter/exporterViewLogic'
import {
@@ -22,7 +23,6 @@ import { OnlineExportContext, QueryExportContext } from '~/types'
import {
dataWarehouseSourcesFromResponse,
- HogQLQueryString,
isAsyncResponse,
isDataTableNode,
isDataVisualizationNode,
diff --git a/frontend/src/queries/utils.test.ts b/frontend/src/queries/utils.test.ts
index a0ecdbcfdefa..d35aa50af966 100644
--- a/frontend/src/queries/utils.test.ts
+++ b/frontend/src/queries/utils.test.ts
@@ -1,24 +1,14 @@
-import { MOCK_TEAM_ID } from 'lib/api.mock'
-
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
-import { dayjs } from 'lib/dayjs'
-import { getAppContext } from 'lib/utils/getAppContext'
-import { teamLogic } from 'scenes/teamLogic'
import { DataTableNode, DataVisualizationNode, Node, NodeKind } from '~/queries/schema/schema-general'
import type { InsightQueryNode } from '~/queries/schema/schema-general'
-import { initKeaTests } from '~/test/init'
-import { AppContext, ChartDisplayType, FunnelVizType, TeamType } from '~/types'
+import { ChartDisplayType, FunnelVizType } from '~/types'
import {
convertDataTableNodeToDataVisualizationNode,
dataWarehouseSourcesFromResponse,
- escapeDottedHogQLIdentifier,
- escapeHogQLString,
- escapePropertyAsHogQLIdentifier,
getDisplay,
getShowLegend,
- hogql,
isMetricInsightQuery,
queryUsesDataWarehouse,
queryVizDefinitelyRendersToCanvas,
@@ -27,141 +17,6 @@ import {
taxonomicSessionFilterToHogQL,
} from './utils'
-window.POSTHOG_APP_CONTEXT = { current_team: { id: MOCK_TEAM_ID } } as unknown as AppContext
-
-describe('hogql tag', () => {
- // In beforeEach (not describe scope): mounting at collection time fires the preflight
- // load before the MSW harness's beforeAll has installed its fetch stub
- beforeEach(() => {
- initKeaTests()
- teamLogic.mount()
- })
-
- it('properly returns query with no substitutions', () => {
- expect(hogql`SELECT * FROM events`).toEqual('SELECT * FROM events')
- })
-
- it('properly returns query with simple identifier substition', () => {
- expect(hogql`SELECT * FROM ${hogql.identifier('events')}`).toEqual('SELECT * FROM events')
- })
-
- it('properly returns query with escaped identifier substition', () => {
- expect(hogql`SELECT properties.${hogql.identifier('odd property')} FROM events`).toEqual(
- 'SELECT properties."odd property" FROM events'
- )
- })
-
- it('properly returns query with string and number substitutions', () => {
- expect(hogql`SELECT * FROM events WHERE properties.foo = ${'bar'} AND properties.baz = ${3}`).toEqual(
- "SELECT * FROM events WHERE properties.foo = 'bar' AND properties.baz = 3"
- )
- })
-
- it('properly returns query with string array substitution', () => {
- expect(hogql`SELECT * FROM events WHERE properties.foo IN ${['bar', 'baz']}`).toEqual(
- "SELECT * FROM events WHERE properties.foo IN ['bar', 'baz']"
- )
- })
-
- it('properly returns query with date substitution in UTC', () => {
- teamLogic.actions.loadCurrentTeamSuccess({ id: MOCK_TEAM_ID, timezone: 'UTC' } as TeamType)
- expect(hogql`SELECT * FROM events WHERE timestamp > ${dayjs('2023-04-04T04:04:00Z')}`).toEqual(
- "SELECT * FROM events WHERE timestamp > '2023-04-04 04:04:00'"
- )
- })
-
- it('properly returns query with date substitution in non-UTC', () => {
- const context = getAppContext()
- let oldTimezone = context?.current_team?.timezone || 'UTC'
- if (context?.current_team) {
- context.current_team.timezone = 'Europe/Moscow'
- }
- teamLogic.actions.loadCurrentTeamSuccess({ id: MOCK_TEAM_ID, timezone: 'Europe/Moscow' } as TeamType)
- expect(hogql`SELECT * FROM events WHERE timestamp > ${dayjs('2023-04-04T04:04:00Z')}`).toEqual(
- "SELECT * FROM events WHERE timestamp > '2023-04-04 07:04:00'" // Offset by 3 hours
- )
- if (context?.current_team) {
- context.current_team.timezone = oldTimezone
- }
- })
-
- it('properly escapes single quotes in string values', () => {
- expect(hogql`SELECT * FROM events WHERE properties.name = ${"O'Reilly"}`).toEqual(
- "SELECT * FROM events WHERE properties.name = 'O\\'Reilly'"
- )
- })
-
- it('properly escapes backslashes in string values', () => {
- expect(hogql`SELECT * FROM events WHERE properties.path = ${'C:\\Users\\test'}`).toEqual(
- "SELECT * FROM events WHERE properties.path = 'C:\\\\Users\\\\test'"
- )
- })
-})
-
-describe('escapeHogQLString', () => {
- it.each([
- ['simple', "'simple'"],
- ["O'Reilly", "'O\\'Reilly'"],
- ["'; DROP TABLE users; --", "'\\'; DROP TABLE users; --'"],
- ['C:\\Users\\test', "'C:\\\\Users\\\\test'"],
- ['line1\nline2', "'line1\\nline2'"],
- ['tab\there', "'tab\\there'"],
- ['carriage\rreturn', "'carriage\\rreturn'"],
- ['', "''"],
- ["multiple'quotes'here", "'multiple\\'quotes\\'here'"],
- ['back\\slash', "'back\\\\slash'"],
- ])('escapes %s to %s', (input, expected) => {
- expect(escapeHogQLString(input)).toEqual(expected)
- })
-})
-
-describe('escapePropertyAsHogQLIdentifier', () => {
- it('leaves simple identifiers unquoted', () => {
- expect(escapePropertyAsHogQLIdentifier('browser')).toEqual('browser')
- expect(escapePropertyAsHogQLIdentifier('$browser')).toEqual('$browser')
- })
-
- it('double-quotes identifiers with special characters but no double quote', () => {
- expect(escapePropertyAsHogQLIdentifier('order items')).toEqual('"order items"')
- })
-
- it('backtick-wraps identifiers containing a double quote', () => {
- expect(escapePropertyAsHogQLIdentifier('a"b')).toEqual('`a"b`')
- })
-
- it('doubles inner backticks when an identifier has both a double quote and a backtick', () => {
- // Backslash-escaping (`a"b\`c`) would be rejected by the HogQL parser; doubling round-trips.
- expect(escapePropertyAsHogQLIdentifier('a"b`c')).toEqual('`a"b``c`')
- })
-
- it('escapes backslashes so they survive the parser instead of forming an escape sequence', () => {
- expect(escapePropertyAsHogQLIdentifier('a\\b')).toEqual('"a\\\\b"')
- expect(escapePropertyAsHogQLIdentifier('end\\')).toEqual('"end\\\\"')
- // A backslash alongside a double quote takes the backtick branch and still escapes both.
- expect(escapePropertyAsHogQLIdentifier('a"\\b')).toEqual('`a"\\\\b`')
- // A backslash immediately before an inner backtick (which forces the backtick branch).
- expect(escapePropertyAsHogQLIdentifier('a"b\\`c')).toEqual('`a"b\\\\``c`')
- })
-
- it('escapes control characters instead of emitting them raw', () => {
- expect(escapePropertyAsHogQLIdentifier('a\tb')).toEqual('"a\\tb"')
- expect(escapePropertyAsHogQLIdentifier('a\nb')).toEqual('"a\\nb"')
- expect(escapePropertyAsHogQLIdentifier('a\bb')).toEqual('"a\\bb"')
- // An embedded double quote forces the backtick branch; the control char is still escaped.
- expect(escapePropertyAsHogQLIdentifier('a"\tb')).toEqual('`a"\\tb`')
- })
-})
-
-describe('escapeDottedHogQLIdentifier', () => {
- it('leaves simple dotted identifiers unquoted', () => {
- expect(escapeDottedHogQLIdentifier('demo.orders')).toEqual('demo.orders')
- })
-
- it('quotes each dotted segment independently when needed', () => {
- expect(escapeDottedHogQLIdentifier('demo.order items')).toEqual('demo."order items"')
- })
-})
-
describe('taxonomicSessionFilterToHogQL', () => {
it('maps session properties to the session prefix', () => {
expect(taxonomicSessionFilterToHogQL(TaxonomicFilterGroupType.SessionProperties, '$entry_current_url')).toEqual(
diff --git a/frontend/src/queries/utils.ts b/frontend/src/queries/utils.ts
index c83820b48390..2ace9880d19a 100644
--- a/frontend/src/queries/utils.ts
+++ b/frontend/src/queries/utils.ts
@@ -1,7 +1,6 @@
import { TaxonomicFilterGroupType, TaxonomicFilterValue } from 'lib/components/TaxonomicFilter/types'
import { MAX_DEFAULT_PROPORTION_LEGEND_PARTS, PERCENT_STACK_VIEW_DISPLAY_TYPE } from 'lib/constants'
-import { dayjs } from 'lib/dayjs'
-import { getAppContext } from 'lib/utils/getAppContext'
+import { escapePropertyAsHogQLIdentifier, isQuoted } from 'lib/utils/hogql'
import { ProductAnalyticsInsightNodeKind } from '~/queries/nodes/InsightQuery/defaults'
import { BIVisualizationNode } from '~/queries/schema/schema-business-intelligence'
@@ -830,13 +829,6 @@ export function filterForQuery(node: ProductAnalyticsInsightQueryNode): InsightF
return node[filterProperty as keyof InsightQueryNode] as InsightFilter | undefined
}
-export function isQuoted(identifier: string): boolean {
- return (
- (identifier.startsWith('"') && identifier.endsWith('"')) ||
- (identifier.startsWith('`') && identifier.endsWith('`'))
- )
-}
-
export function trimQuotes(identifier: string): string {
if (isQuoted(identifier)) {
return identifier.slice(1, -1)
@@ -844,52 +836,6 @@ export function trimQuotes(identifier: string): string {
return identifier
}
-// Mirrors escape_chars_map in posthog/hogql/escape_sql.py: backslash and control chars must be escaped so a quoted identifier round-trips losslessly through the HogQL parser.
-const HOGQL_IDENTIFIER_ESCAPE_MAP: Record<string, string> = {
- '\b': '\\b',
- '\f': '\\f',
- '\r': '\\r',
- '\n': '\\n',
- '\t': '\\t',
- '\0': '\\0',
- '\x07': '\\a',
- '\v': '\\v',
- '\\': '\\\\',
-}
-
-/** Make sure the property key is wrapped in quotes if it contains any special characters. */
-export function escapePropertyAsHogQLIdentifier(identifier: string): string {
- if (identifier.match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) {
- // Same regex as in the backend escape_hogql_identifier
- return identifier // This identifier is simple
- }
- if (isQuoted(identifier)) {
- return identifier // This identifier is already quoted
- }
- return escapeRawPropertyAsHogQLIdentifier(identifier)
-}
-
-export function escapeRawPropertyAsHogQLIdentifier(identifier: string): string {
- if (identifier.match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) {
- return identifier
- }
- // Escape backslashes and control chars, then wrap; double an inner backtick (the parser rejects a backslash-escaped delimiter). The double-quote path needs no quote escaping since it is only taken when the identifier has no `"`.
- const escaped = Array.from(identifier, (c) => HOGQL_IDENTIFIER_ESCAPE_MAP[c] || c).join('')
- return !identifier.includes('"') ? `"${escaped}"` : `\`${escaped.replaceAll('`', '``')}\``
-}
-
-/** Quote each segment of a dotted HogQL reference independently. */
-export function escapeDottedHogQLIdentifier(identifier: string): string {
- if (isQuoted(identifier) || !identifier.includes('.')) {
- return escapePropertyAsHogQLIdentifier(identifier)
- }
-
- return identifier
- .split('.')
- .map((segment) => escapePropertyAsHogQLIdentifier(segment))
- .join('.')
-}
-
export function taxonomicEventFilterToHogQL(
groupType: TaxonomicFilterGroupType,
value: TaxonomicFilterValue
@@ -967,98 +913,6 @@ export function isHogQLAggregation(hogQl: string): boolean {
)
}
-declare const __hogqlBrand: unique symbol
-export type HogQLQueryString = string & { readonly [__hogqlBrand]: void }
-
-export interface HogQLIdentifier {
- __hogql_identifier: true
- identifier: string
-}
-
-function hogQLIdentifier(identifier: string): HogQLIdentifier {
- return {
- __hogql_identifier: true,
- identifier,
- }
-}
-
-function isHogQLIdentifier(value: any): value is HogQLIdentifier {
- return !!value?.__hogql_identifier
-}
-
-export interface HogQLRaw {
- __hogql_raw: true
- raw: string
-}
-
-function hogQLRaw(raw: string): HogQLRaw {
- return {
- __hogql_raw: true,
- raw,
- }
-}
-
-function isHogQLRaw(value: any): value is HogQLRaw {
- return !!value?.__hogql_raw
-}
-
-const ESCAPE_CHARS_MAP: Record<string, string> = {
- '\b': '\\b',
- '\f': '\\f',
- '\r': '\\r',
- '\n': '\\n',
- '\t': '\\t',
- '\0': '\\0',
- '\x07': '\\a',
- '\v': '\\v',
- '\\': '\\\\',
- "'": "\\'",
-}
-
-export function escapeHogQLString(value: string): string {
- let escaped = ''
- for (const char of value) {
- escaped += ESCAPE_CHARS_MAP[char] ?? char
- }
- return `'${escaped}'`
-}
-
-function formatHogQLValue(value: any): string {
- if (Array.isArray(value)) {
- return `[${value.map(formatHogQLValue).join(', ')}]`
- } else if (dayjs.isDayjs(value)) {
- const timezone = getAppContext()?.current_team?.timezone || 'UTC'
- return value.tz(timezone).format("'YYYY-MM-DD HH:mm:ss'")
- } else if (isHogQLIdentifier(value)) {
- return escapePropertyAsHogQLIdentifier(value.identifier)
- } else if (isHogQLRaw(value)) {
- return value.raw
- } else if (typeof value === 'string') {
- return escapeHogQLString(value)
- } else if (typeof value === 'number') {
- return String(value)
- } else if (value === null) {
- throw new Error(
- `null cannot be interpolated for SQL. if a null check is needed, make 'IS NULL' part of your query`
- )
- } else {
- throw new Error(`Unsupported interpolated value type: ${typeof value}`)
- }
-}
-
-/**
- * Template tag for HogQL formatting. Handles formatting of values for you.
- * @example hogql`SELECT * FROM events WHERE properties.text = ${text} AND timestamp > ${dayjs()}`
- */
-export function hogql(strings: TemplateStringsArray, ...values: any[]): HogQLQueryString {
- return strings.reduce(
- (acc, str, i) => acc + str + (i < strings.length - 1 ? formatHogQLValue(values[i]) : ''),
- ''
- ) as unknown as HogQLQueryString
-}
-hogql.identifier = hogQLIdentifier
-hogql.raw = hogQLRaw
-
type SingleBreakdownFilter = BreakdownFilter & {
breakdown: NonNullable<BreakdownFilter['breakdown']>
}
diff --git a/frontend/src/scenes/activity/live/liveEventsQuery.ts b/frontend/src/scenes/activity/live/liveEventsQuery.ts
index 0cafa1f2e488..bc793c8c19da 100644
--- a/frontend/src/scenes/activity/live/liveEventsQuery.ts
+++ b/frontend/src/scenes/activity/live/liveEventsQuery.ts
@@ -1,6 +1,6 @@
import api from 'lib/api'
+import { hogql } from 'lib/utils/hogql'
-import { hogql } from '~/queries/utils'
import { LiveEvent } from '~/types'
export const LIVE_EVENTS_QUERY_POLL_MS = 10000
diff --git a/frontend/src/scenes/data-warehouse/editor/sidebar/QueryDatabase.tsx b/frontend/src/scenes/data-warehouse/editor/sidebar/QueryDatabase.tsx
index aa6b6d58d90f..467188cba1e1 100644
--- a/frontend/src/scenes/data-warehouse/editor/sidebar/QueryDatabase.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/sidebar/QueryDatabase.tsx
@@ -37,6 +37,7 @@ import {
import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { cn } from 'lib/utils/css-classes'
+import { escapeDottedHogQLIdentifier, escapePropertyAsHogQLIdentifier } from 'lib/utils/hogql'
import { newInternalTab } from 'lib/utils/newInternalTab'
import {
MANAGED_TRINO_SCHEMA_SCOPE,
@@ -49,7 +50,6 @@ import { urls } from 'scenes/urls'
import { SearchHighlightMultiple } from '~/layout/navigation-3000/components/SearchHighlight'
import { DatabaseSerializedFieldType } from '~/queries/schema/schema-general'
-import { escapeDottedHogQLIdentifier, escapePropertyAsHogQLIdentifier } from '~/queries/utils'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
import { endpointModelUrl } from 'products/data_modeling/frontend/endpointModelName'
diff --git a/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx b/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx
index 3c9c0aad3199..a3f796a8b43c 100644
--- a/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/sidebar/queryDatabaseLogic.tsx
@@ -24,6 +24,7 @@ import { LemonTreeRef, TreeDataItem } from 'lib/lemon-ui/LemonTree/LemonTree'
import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { uuid } from 'lib/utils/dom'
import { createFuse, IFuseOptions } from 'lib/utils/fuseSearch'
+import { escapeDottedHogQLIdentifier, escapeRawPropertyAsHogQLIdentifier } from 'lib/utils/hogql'
import { newInternalTab } from 'lib/utils/newInternalTab'
import {
MANAGED_TRINO_SCHEMA_SCOPE,
@@ -43,7 +44,6 @@ import {
DatabaseSchemaManagedViewTable,
DatabaseSchemaTable,
} from '~/queries/schema/schema-general'
-import { escapeDottedHogQLIdentifier, escapeRawPropertyAsHogQLIdentifier } from '~/queries/utils'
import {
DataWarehouseSavedQueryDraft,
DataWarehouseSavedQueryFolder,
diff --git a/frontend/src/scenes/feature-flags/featureFlagUsageQueries.ts b/frontend/src/scenes/feature-flags/featureFlagUsageQueries.ts
index 796763091a68..302fdfbd7f07 100644
--- a/frontend/src/scenes/feature-flags/featureFlagUsageQueries.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagUsageQueries.ts
@@ -8,6 +8,7 @@
// names are pinned, while these use sentence case. The interval here follows the user's date range
// rather than the saved dashboards' fixed "day".
import { dateMapping, dateStringToDayJs, getDefaultInterval } from 'lib/utils/dateFilters'
+import { escapeHogQLString } from 'lib/utils/hogql'
import { BREAKDOWN_NULL_DISPLAY } from 'scenes/insights/utils'
import { Noun } from '~/models/groupsModel'
@@ -22,7 +23,7 @@ import {
TrendsQuery,
} from '~/queries/schema/schema-general'
import { QueryContext } from '~/queries/types'
-import { escapeHogQLString, setLatestVersionsOnQuery } from '~/queries/utils'
+import { setLatestVersionsOnQuery } from '~/queries/utils'
import {
AnyPropertyFilter,
BaseMathType,
diff --git a/frontend/src/scenes/hog-functions/configuration/hogFunctionConfigurationLogic.tsx b/frontend/src/scenes/hog-functions/configuration/hogFunctionConfigurationLogic.tsx
index 7f7627d06cfb..2830c737186b 100644
--- a/frontend/src/scenes/hog-functions/configuration/hogFunctionConfigurationLogic.tsx
+++ b/frontend/src/scenes/hog-functions/configuration/hogFunctionConfigurationLogic.tsx
@@ -33,6 +33,7 @@ import { dayjs } from 'lib/dayjs'
import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import { deleteWithUndo } from 'lib/utils/deleteWithUndo'
import { uuid } from 'lib/utils/dom'
+import { escapePropertyAsHogQLIdentifier } from 'lib/utils/hogql'
import { addProductIntent } from 'lib/utils/product-intents'
import { FEATURE_FLAG_CALLED_EVENT } from 'scenes/feature-flags/flagEvaluationsTable'
import { projectLogic } from 'scenes/projectLogic'
@@ -53,7 +54,7 @@ import {
ProductKey,
TrendsQuery,
} from '~/queries/schema/schema-general'
-import { escapePropertyAsHogQLIdentifier, setLatestVersionsOnQuery } from '~/queries/utils'
+import { setLatestVersionsOnQuery } from '~/queries/utils'
import {
AnyPropertyFilter,
AvailableFeature,
diff --git a/frontend/src/scenes/hog-functions/filters/flagCallsMatching.ts b/frontend/src/scenes/hog-functions/filters/flagCallsMatching.ts
index 6051bc6c69be..72b41f0fd49d 100644
--- a/frontend/src/scenes/hog-functions/filters/flagCallsMatching.ts
+++ b/frontend/src/scenes/hog-functions/filters/flagCallsMatching.ts
@@ -1,9 +1,10 @@
import { convertPropertiesToPropertyGroup, isEventPropertyFilter } from 'lib/components/PropertyFilters/utils'
+import { hogql } from 'lib/utils/hogql'
import { FEATURE_FLAG_CALLED_EVENT, storesFlagCallsOutsideEvents } from 'scenes/feature-flags/flagEvaluationsTable'
import { performQuery } from '~/queries/query'
import { EventsQuery, NodeKind, TrendsQuery } from '~/queries/schema/schema-general'
-import { hogql, setLatestVersionsOnQuery } from '~/queries/utils'
+import { setLatestVersionsOnQuery } from '~/queries/utils'
import {
CyclotronJobFilterPropertyFilter,
CyclotronJobInvocationGlobals,
diff --git a/frontend/src/scenes/hog-functions/filters/matchingFilters.ts b/frontend/src/scenes/hog-functions/filters/matchingFilters.ts
index c8a460ebb122..5994533f7e1f 100644
--- a/frontend/src/scenes/hog-functions/filters/matchingFilters.ts
+++ b/frontend/src/scenes/hog-functions/filters/matchingFilters.ts
@@ -1,4 +1,5 @@
-import { hogql } from '~/queries/utils'
+import { hogql } from 'lib/utils/hogql'
+
import {
AnyPropertyFilter,
CyclotronJobFilterActions,
diff --git a/frontend/src/scenes/hog-functions/invocations/HogInvocations.tsx b/frontend/src/scenes/hog-functions/invocations/HogInvocations.tsx
index 3a6ec63c04cc..c44e74c52051 100644
--- a/frontend/src/scenes/hog-functions/invocations/HogInvocations.tsx
+++ b/frontend/src/scenes/hog-functions/invocations/HogInvocations.tsx
@@ -29,9 +29,9 @@ import { TZLabel } from 'lib/components/TZLabel'
import { dayjs } from 'lib/dayjs'
import { Link } from 'lib/lemon-ui/Link'
import { DATE_TIME_FORMAT, formatDateRange } from 'lib/utils/datetime'
+import { escapeHogQLString, hogql } from 'lib/utils/hogql'
import { urls } from 'scenes/urls'
-import { escapeHogQLString, hogql } from '~/queries/utils'
import { DateMappingOption, HogFunctionTypeType, PersonType } from '~/types'
import { PersonDisplay } from 'products/persons/frontend/components/PersonDisplay'
diff --git a/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsx b/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsx
index 8d7a6f86c8ef..baadcb4135f5 100644
--- a/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsx
+++ b/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsx
@@ -8,9 +8,9 @@ import api, { ApiConfig } from 'lib/api'
import { dayjs } from 'lib/dayjs'
import { dateStringToDayJs } from 'lib/utils/dateFilters'
import { getAppContext } from 'lib/utils/getAppContext'
+import { escapeHogQLString, hogql } from 'lib/utils/hogql'
import { teamLogic } from 'scenes/teamLogic'
-import { escapeHogQLString, hogql } from '~/queries/utils'
import { HogFunctionTypeType, LogEntryLevel, PersonType } from '~/types'
import { hogFunctionsRerunCreate } from 'products/cdp/frontend/generated/api'
diff --git a/frontend/src/scenes/hog-functions/logs/hogFunctionLogsLogic.ts b/frontend/src/scenes/hog-functions/logs/hogFunctionLogsLogic.ts
index 3de54807a4c7..81412ed38507 100644
--- a/frontend/src/scenes/hog-functions/logs/hogFunctionLogsLogic.ts
+++ b/frontend/src/scenes/hog-functions/logs/hogFunctionLogsLogic.ts
@@ -5,8 +5,8 @@ import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
import { Dayjs, dayjs } from 'lib/dayjs'
+import { hogql } from 'lib/utils/hogql'
-import { hogql } from '~/queries/utils'
import { LogEntryLevel } from '~/types'
import { GroupedLogEntry, LogsViewerLogicProps, logsViewerLogic } from './logsViewerLogic'
diff --git a/frontend/src/scenes/hog-functions/logs/logsViewerLogic.tsx b/frontend/src/scenes/hog-functions/logs/logsViewerLogic.tsx
index c596e406ef7c..66eafc1ea679 100644
--- a/frontend/src/scenes/hog-functions/logs/logsViewerLogic.tsx
+++ b/frontend/src/scenes/hog-functions/logs/logsViewerLogic.tsx
@@ -19,9 +19,9 @@ import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
import { Dayjs, dayjs } from 'lib/dayjs'
+import { HogQLQueryString, hogql } from 'lib/utils/hogql'
import { teamLogic } from 'scenes/teamLogic'
-import { HogQLQueryString, hogql } from '~/queries/utils'
import { LogEntryLevel } from '~/types'
export const ALL_LOG_LEVELS: LogEntryLevel[] = ['DEBUG', 'LOG', 'INFO', 'WARN', 'ERROR']
diff --git a/frontend/src/scenes/onboarding/sdks/sdksLogic.tsx b/frontend/src/scenes/onboarding/sdks/sdksLogic.tsx
index 5ed770b92703..983603d6c924 100644
--- a/frontend/src/scenes/onboarding/sdks/sdksLogic.tsx
+++ b/frontend/src/scenes/onboarding/sdks/sdksLogic.tsx
@@ -7,11 +7,11 @@ import api from 'lib/api'
import { LemonSelectOptions } from 'lib/lemon-ui/LemonSelect/LemonSelect'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
+import { hogql } from 'lib/utils/hogql'
import { liveEventsLogic } from 'scenes/activity/live/liveEventsLogic'
import { userLogic } from 'scenes/userLogic'
import { ProductKey } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { SDK, SDKDocsLinkOverrides, SDKInstructionsMap, SDKTag, SDKTagOverrides } from '~/types'
import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'
diff --git a/frontend/src/scenes/session-recordings/components/liveRecordingsCountLogic.ts b/frontend/src/scenes/session-recordings/components/liveRecordingsCountLogic.ts
index c15c48621bbf..d4d93d50b5fe 100644
--- a/frontend/src/scenes/session-recordings/components/liveRecordingsCountLogic.ts
+++ b/frontend/src/scenes/session-recordings/components/liveRecordingsCountLogic.ts
@@ -1,10 +1,10 @@
import { MakeLogicType, actions, connect, events, kea, listeners, path, reducers } from 'kea'
import { LIVE_COUNT_REFRESH_MS, loadCachedLiveCount } from 'lib/components/LiveUserCount/liveCountCache'
+import { hogql } from 'lib/utils/hogql'
import { teamLogic } from 'scenes/teamLogic'
import { QueryLogTags } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
const QUERY_TAGS: QueryLogTags = { scene: 'Replay', productKey: 'session_replay' }
diff --git a/frontend/src/scenes/session-recordings/player/sessionEventsDataLogic.ts b/frontend/src/scenes/session-recordings/player/sessionEventsDataLogic.ts
index a6481e769010..7b358fa2b1dc 100644
--- a/frontend/src/scenes/session-recordings/player/sessionEventsDataLogic.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionEventsDataLogic.ts
@@ -23,10 +23,10 @@ import api from 'lib/api'
import { Dayjs, dayjs } from 'lib/dayjs'
import { chainToElements } from 'lib/utils/elements-chain'
import { getEventsWithPrimaryProperty } from 'lib/utils/events'
+import { HogQLQueryString, hogql } from 'lib/utils/hogql'
import { TimeTree } from 'lib/utils/time-tree'
import { primaryEventPropertiesModel } from '~/models/primaryEventPropertiesModel'
-import { HogQLQueryString, hogql } from '~/queries/utils'
import { RecordingEventType } from '~/types'
import type { SessionRecordingType } from '../../../types'
diff --git a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsListPropertiesLogic.ts b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsListPropertiesLogic.ts
index 52c9e70d653f..2b70378e6952 100644
--- a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsListPropertiesLogic.ts
+++ b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsListPropertiesLogic.ts
@@ -4,10 +4,10 @@ import posthog from 'posthog-js'
import api, { ApiError } from 'lib/api'
import { dayjs } from 'lib/dayjs'
+import { HogQLQueryString, escapePropertyAsHogQLIdentifier, hogql } from 'lib/utils/hogql'
import { sessionRecordingEventUsageLogic } from 'scenes/session-recordings/sessionRecordingEventUsageLogic'
import { QueryLogTags } from '~/queries/schema/schema-general'
-import { HogQLQueryString, escapePropertyAsHogQLIdentifier, hogql } from '~/queries/utils'
import { CORE_FILTER_DEFINITIONS_BY_GROUP } from '~/taxonomy/taxonomy'
import { SessionRecordingPropertiesType, SessionRecordingType } from '~/types'
diff --git a/frontend/src/scenes/sessions/sessionProfileLogic.ts b/frontend/src/scenes/sessions/sessionProfileLogic.ts
index a685f9e139da..4d09686efca3 100644
--- a/frontend/src/scenes/sessions/sessionProfileLogic.ts
+++ b/frontend/src/scenes/sessions/sessionProfileLogic.ts
@@ -2,9 +2,9 @@ import { MakeLogicType, actions, connect, events, kea, key, listeners, path, pro
import { loaders } from 'kea-loaders'
import api from 'lib/api'
+import { hogql } from 'lib/utils/hogql'
import { NodeKind } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { SessionEventType } from '~/types'
import type { TeamPublicType, TeamType } from '../../types'
diff --git a/frontend/src/scenes/settings/project/gatewayKeySpendQuery.ts b/frontend/src/scenes/settings/project/gatewayKeySpendQuery.ts
index 6f09ef75b4e2..072c0c49dcec 100644
--- a/frontend/src/scenes/settings/project/gatewayKeySpendQuery.ts
+++ b/frontend/src/scenes/settings/project/gatewayKeySpendQuery.ts
@@ -1,7 +1,7 @@
import api from 'lib/api'
+import { hogql } from 'lib/utils/hogql'
import { ProductKey } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
export const GATEWAY_SPEND_WINDOW_DAYS = 30
diff --git a/frontend/src/scenes/surveys/components/SurveyUrlAudienceEstimate.tsx b/frontend/src/scenes/surveys/components/SurveyUrlAudienceEstimate.tsx
index 63afd6dc8275..73d2cda7e808 100644
--- a/frontend/src/scenes/surveys/components/SurveyUrlAudienceEstimate.tsx
+++ b/frontend/src/scenes/surveys/components/SurveyUrlAudienceEstimate.tsx
@@ -7,9 +7,9 @@ import { Spinner } from '@posthog/lemon-ui'
import api from 'lib/api'
import { cn } from 'lib/utils/css-classes'
import { uuid } from 'lib/utils/dom'
+import { type HogQLQueryString } from 'lib/utils/hogql'
import { humanFriendlyNumber } from 'lib/utils/numbers'
-import type { HogQLQueryString } from '~/queries/utils'
import { PropertyFilterType, PropertyOperator, SurveyDisplayConditions, SurveyMatchType } from '~/types'
import { surveyLogic } from '../surveyLogic'
diff --git a/frontend/src/scenes/surveys/surveyLogic.tsx b/frontend/src/scenes/surveys/surveyLogic.tsx
index 3858d356124d..e63b456acfab 100644
--- a/frontend/src/scenes/surveys/surveyLogic.tsx
+++ b/frontend/src/scenes/surveys/surveyLogic.tsx
@@ -29,6 +29,7 @@ import { dayjs } from 'lib/dayjs'
import { FeatureFlagsSet, featureFlagLogic as enabledFlagLogic } from 'lib/logic/featureFlagLogic'
import { deleteWithUndo } from 'lib/utils/deleteWithUndo'
import { isObject } from 'lib/utils/guards'
+import { HogQLQueryString } from 'lib/utils/hogql'
import { hasFormErrors, objectClean } from 'lib/utils/objects'
import { allOperatorsMapping } from 'lib/utils/operators'
import { showApprovalRequiredToast } from 'scenes/approvals/ApprovalRequiredBanner'
@@ -61,7 +62,6 @@ import {
ProductKey,
} from '~/queries/schema/schema-general'
import { SurveyAnalysisQuestionGroup, SurveyAnalysisResponseItem } from '~/queries/schema/schema-surveys'
-import { HogQLQueryString } from '~/queries/utils'
import {
ActivityScope,
AnyPropertyFilter,
diff --git a/frontend/src/scenes/surveys/surveyNotificationModalLogic.ts b/frontend/src/scenes/surveys/surveyNotificationModalLogic.ts
index 1a5c3f65b13f..a0e1baee38c4 100644
--- a/frontend/src/scenes/surveys/surveyNotificationModalLogic.ts
+++ b/frontend/src/scenes/surveys/surveyNotificationModalLogic.ts
@@ -8,6 +8,7 @@ import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
import { integrationsLogic } from 'lib/integrations/integrationsLogic'
+import { hogql } from 'lib/utils/hogql'
import { convertToHogFunctionInvocationGlobals } from 'scenes/hog-functions/configuration/hogFunctionConfigurationLogic'
import { DESTINATION_OPTIONS, DestinationKey } from 'scenes/hog-functions/list/newNotificationDialogLogic'
import {
@@ -33,7 +34,6 @@ import { urls } from 'scenes/urls'
import { performQuery } from '~/queries/query'
import { EventsQuery, NodeKind } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import {
AnyPropertyFilter,
CyclotronJobFilterEvents,
diff --git a/frontend/src/scenes/surveys/utils.ts b/frontend/src/scenes/surveys/utils.ts
index 9688863973ac..35a143c82fec 100644
--- a/frontend/src/scenes/surveys/utils.ts
+++ b/frontend/src/scenes/surveys/utils.ts
@@ -6,6 +6,7 @@ import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { dayjs } from 'lib/dayjs'
import { dateStringToDayJs } from 'lib/utils/dateFilters'
import { getAppContext } from 'lib/utils/getAppContext'
+import { escapeRawPropertyAsHogQLIdentifier } from 'lib/utils/hogql'
import {
INTRO_SCREEN_PAGE_INDEX,
MAX_ITERATION_COUNT,
@@ -20,7 +21,6 @@ import { urls } from 'scenes/urls'
import type { DataTableRow } from '~/queries/nodes/DataTable/dataTableLogic'
import { DataTableNode, HogQLQuery, NodeKind } from '~/queries/schema/schema-general'
-import { escapeRawPropertyAsHogQLIdentifier } from '~/queries/utils'
import { getFilterLabel } from '~/taxonomy/helpers'
import {
BasicSurveyQuestion,
diff --git a/frontend/src/scenes/web-analytics/common.ts b/frontend/src/scenes/web-analytics/common.ts
index 487af7063feb..81907b1d79a2 100644
--- a/frontend/src/scenes/web-analytics/common.ts
+++ b/frontend/src/scenes/web-analytics/common.ts
@@ -7,6 +7,7 @@ import { PostHogComDocsURL } from 'lib/lemon-ui/Link/Link'
import { type FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
import { getDefaultInterval } from 'lib/utils/dateFilters'
import { UnexpectedNeverError } from 'lib/utils/guards'
+import { hogql } from 'lib/utils/hogql'
import { pageCollectionId } from '~/queries/nodes/DataNode/pageCollections'
import { hogqlQuery } from '~/queries/query'
@@ -19,7 +20,6 @@ import {
WebAnalyticsPropertyFilters,
WebStatsBreakdown,
} from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { InsightLogicProps, PropertyFilterType, PropertyMathType, PropertyOperator } from '~/types'
/** Matches BREAKDOWN_NULL_DISPLAY in products/web_analytics/backend/hogql_queries/stats_table.py */
diff --git a/frontend/src/scenes/web-analytics/pagePerformanceLogic.ts b/frontend/src/scenes/web-analytics/pagePerformanceLogic.ts
index 491e67198318..b95a02da7cd1 100644
--- a/frontend/src/scenes/web-analytics/pagePerformanceLogic.ts
+++ b/frontend/src/scenes/web-analytics/pagePerformanceLogic.ts
@@ -16,6 +16,7 @@ import {
import { subscriptions } from 'kea-subscriptions'
import { dayjs } from 'lib/dayjs'
+import { escapeHogQLString } from 'lib/utils/hogql'
import { isAbortedRequest } from 'lib/utils/requests'
import { pluralize } from 'lib/utils/strings'
import { teamLogic } from 'scenes/teamLogic'
@@ -39,7 +40,6 @@ import {
WebStatsBreakdown,
WebStatsTableQuery,
} from '~/queries/schema/schema-general'
-import { escapeHogQLString } from '~/queries/utils'
import { ActionType, BaseMathType, ChartDisplayType, InsightLogicProps, TeamType } from '~/types'
import {
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
index 9f14df8f060a..439f4245d07c 100644
--- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
+++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
@@ -39,6 +39,7 @@ import { getDefaultInterval, isValidRelativeOrAbsoluteDate } from 'lib/utils/dat
import { isDefinitionStale } from 'lib/utils/definitions'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { UnexpectedNeverError, isNotNil } from 'lib/utils/guards'
+import { hogql } from 'lib/utils/hogql'
import { objectsEqual } from 'lib/utils/objects'
import { addProductIntentForCrossSell } from 'lib/utils/product-intents'
import { Scene } from 'scenes/sceneTypes'
@@ -72,7 +73,6 @@ import {
WebStatsTableQuery,
WebVitalsMetric,
} from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import {
AvailableFeature,
BaseMathType,
diff --git a/products/ai_observability/frontend/aiObservabilityAIDataLogic.ts b/products/ai_observability/frontend/aiObservabilityAIDataLogic.ts
index a12af1839d30..5a328883cb22 100644
--- a/products/ai_observability/frontend/aiObservabilityAIDataLogic.ts
+++ b/products/ai_observability/frontend/aiObservabilityAIDataLogic.ts
@@ -3,9 +3,9 @@ import { MakeLogicType, actions, events, kea, listeners, path, reducers, selecto
import api from 'lib/api'
import { Dayjs, dayjs } from 'lib/dayjs'
import { chunk } from 'lib/utils/arrays'
+import { hogql } from 'lib/utils/hogql'
import { ProductKey } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { parsePartialJSON, selectAiValue } from './utils'
diff --git a/products/ai_observability/frontend/aiObservabilityColumnRenderers.tsx b/products/ai_observability/frontend/aiObservabilityColumnRenderers.tsx
index d821797fbe00..cfd2c53170a4 100644
--- a/products/ai_observability/frontend/aiObservabilityColumnRenderers.tsx
+++ b/products/ai_observability/frontend/aiObservabilityColumnRenderers.tsx
@@ -6,12 +6,13 @@ import { IconFilter } from '@posthog/icons'
import { LemonButton, LemonTag, Link } from '@posthog/lemon-ui'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
+import { hogql } from 'lib/utils/hogql'
import { urls } from 'scenes/urls'
import { DataTableNode, VisualizationNode } from '~/queries/schema/schema-general'
import { LLMTrace } from '~/queries/schema/schema-general'
import { QueryContextColumn } from '~/queries/types'
-import { hogql, isDataTableNode, isEventsQuery } from '~/queries/utils'
+import { isDataTableNode, isEventsQuery } from '~/queries/utils'
import { AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
import { PersonDisplay, PersonIcon } from 'products/persons/frontend/components/PersonDisplay'
diff --git a/products/ai_observability/frontend/clusters/clusterDetailLogic.ts b/products/ai_observability/frontend/clusters/clusterDetailLogic.ts
index 0d2ce9ceee83..771fbf6ff5f5 100644
--- a/products/ai_observability/frontend/clusters/clusterDetailLogic.ts
+++ b/products/ai_observability/frontend/clusters/clusterDetailLogic.ts
@@ -6,11 +6,11 @@ import posthog from 'posthog-js'
import api from 'lib/api'
import { getSeriesColor } from 'lib/colors'
import { dayjs } from 'lib/dayjs'
+import { hogql } from 'lib/utils/hogql'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { AnyPropertyFilter, Breadcrumb } from '~/types'
import type { ProductIntentProperties } from '../../../../frontend/src/lib/utils/product-intents'
diff --git a/products/ai_observability/frontend/clusters/clusterMetricsLoader.ts b/products/ai_observability/frontend/clusters/clusterMetricsLoader.ts
index 465450455fb3..d25c8a59e992 100644
--- a/products/ai_observability/frontend/clusters/clusterMetricsLoader.ts
+++ b/products/ai_observability/frontend/clusters/clusterMetricsLoader.ts
@@ -1,6 +1,5 @@
import api from 'lib/api'
-
-import { hogql } from '~/queries/utils'
+import { hogql } from 'lib/utils/hogql'
import { Cluster, ClusterMetrics, ClusteringLevel } from './types'
diff --git a/products/ai_observability/frontend/clusters/clustersLogic.ts b/products/ai_observability/frontend/clusters/clustersLogic.ts
index f6ff0d6a7ac7..2c647e583e44 100644
--- a/products/ai_observability/frontend/clusters/clustersLogic.ts
+++ b/products/ai_observability/frontend/clusters/clustersLogic.ts
@@ -8,9 +8,9 @@ import { getSeriesColor } from 'lib/colors'
import { dayjs } from 'lib/dayjs'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'
+import { hogql } from 'lib/utils/hogql'
import { urls } from 'scenes/urls'
-import { hogql } from '~/queries/utils'
import { AnyPropertyFilter, Breadcrumb } from '~/types'
import { aiObservabilitySharedLogic } from '../aiObservabilitySharedLogic'
diff --git a/products/ai_observability/frontend/clusters/filteredItemIdsLoader.ts b/products/ai_observability/frontend/clusters/filteredItemIdsLoader.ts
index c36df8cf42cc..3614946b5901 100644
--- a/products/ai_observability/frontend/clusters/filteredItemIdsLoader.ts
+++ b/products/ai_observability/frontend/clusters/filteredItemIdsLoader.ts
@@ -1,6 +1,6 @@
import api from 'lib/api'
+import { HogQLQueryString, hogql } from 'lib/utils/hogql'
-import { HogQLQueryString, hogql } from '~/queries/utils'
import { AnyPropertyFilter } from '~/types'
import { FILTER_QUERY_MAX_ROWS, SAFE_ID_RE, TRACE_MEMBER_EVENTS } from './constants'
diff --git a/products/ai_observability/frontend/clusters/traceSummaryLoader.ts b/products/ai_observability/frontend/clusters/traceSummaryLoader.ts
index 3e09db9d2909..ad7ac3f8d3b3 100644
--- a/products/ai_observability/frontend/clusters/traceSummaryLoader.ts
+++ b/products/ai_observability/frontend/clusters/traceSummaryLoader.ts
@@ -1,6 +1,5 @@
import api from 'lib/api'
-
-import { hogql } from '~/queries/utils'
+import { hogql } from 'lib/utils/hogql'
import { ClusteringLevel, TraceSummary } from './types'
diff --git a/products/ai_observability/frontend/components/clustersTabContentLogic.ts b/products/ai_observability/frontend/components/clustersTabContentLogic.ts
index 4d0317d67e3c..88e9fca488d6 100644
--- a/products/ai_observability/frontend/components/clustersTabContentLogic.ts
+++ b/products/ai_observability/frontend/components/clustersTabContentLogic.ts
@@ -3,8 +3,7 @@ import { loaders } from 'kea-loaders'
import posthog from 'posthog-js'
import api from 'lib/api'
-
-import { hogql } from '~/queries/utils'
+import { hogql } from 'lib/utils/hogql'
import { CLUSTERING_RUNS_LOOKBACK_DAYS, NOISE_CLUSTER_ID } from '../clusters/constants'
import { Cluster } from '../clusters/types'
diff --git a/products/ai_observability/frontend/emptyState/clustersSetupLogic.ts b/products/ai_observability/frontend/emptyState/clustersSetupLogic.ts
index 0ae3e10c253a..e81034ef54e4 100644
--- a/products/ai_observability/frontend/emptyState/clustersSetupLogic.ts
+++ b/products/ai_observability/frontend/emptyState/clustersSetupLogic.ts
@@ -1,8 +1,8 @@
import api from 'lib/api'
import { createSetupDetectionLogic } from 'lib/components/ProductEmptyState/setupDetectionLogic'
+import { hogql } from 'lib/utils/hogql'
import { ProductKey } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { CLUSTERING_RUNS_LOOKBACK_DAYS } from '../clusters/constants'
import { hasRecentAIEvents } from '../utils/aiEvents'
diff --git a/products/ai_observability/frontend/evaluations/constants.ts b/products/ai_observability/frontend/evaluations/constants.ts
index 48f9896f496d..df663db07a43 100644
--- a/products/ai_observability/frontend/evaluations/constants.ts
+++ b/products/ai_observability/frontend/evaluations/constants.ts
@@ -1,4 +1,4 @@
-import { escapeHogQLString } from '~/queries/utils'
+import { escapeHogQLString } from 'lib/utils/hogql'
import type {
EvaluationConfig,
diff --git a/products/ai_observability/frontend/evaluations/evaluationPassRateTrendsQuery.ts b/products/ai_observability/frontend/evaluations/evaluationPassRateTrendsQuery.ts
index 7caccf663cee..0369ced0d400 100644
--- a/products/ai_observability/frontend/evaluations/evaluationPassRateTrendsQuery.ts
+++ b/products/ai_observability/frontend/evaluations/evaluationPassRateTrendsQuery.ts
@@ -1,5 +1,6 @@
+import { escapeHogQLString } from 'lib/utils/hogql'
+
import { NodeKind, TrendsQuery } from '~/queries/schema/schema-general'
-import { escapeHogQLString } from '~/queries/utils'
import { ChartDisplayType, HogQLMathType, PropertyFilterType, PropertyOperator } from '~/types'
import {
diff --git a/products/ai_observability/frontend/evaluations/overview/evaluationDetailResultsLogic.ts b/products/ai_observability/frontend/evaluations/overview/evaluationDetailResultsLogic.ts
index 63074d12e4c6..0302929ca8fc 100644
--- a/products/ai_observability/frontend/evaluations/overview/evaluationDetailResultsLogic.ts
+++ b/products/ai_observability/frontend/evaluations/overview/evaluationDetailResultsLogic.ts
@@ -4,12 +4,12 @@ import posthog from 'posthog-js'
import { dayjs } from 'lib/dayjs'
import { uuid } from 'lib/utils/dom'
+import { escapeHogQLString, escapePropertyAsHogQLIdentifier } from 'lib/utils/hogql'
import { teamLogic } from 'scenes/teamLogic'
import { cancelQueryOnServer } from '~/queries/nodes/DataNode/dataNodeLogic'
import { performQuery } from '~/queries/query'
import { DateRange, NodeKind, TrendsQuery, TrendsQueryResponse } from '~/queries/schema/schema-general'
-import { escapeHogQLString, escapePropertyAsHogQLIdentifier } from '~/queries/utils'
import { HogQLMathType, type HogQLPropertyFilter, PropertyFilterType } from '~/types'
import { evaluationsOverviewRetrieve } from '../../generated/api'
diff --git a/products/ai_observability/frontend/feedback-view/feedbackViewLogic.ts b/products/ai_observability/frontend/feedback-view/feedbackViewLogic.ts
index 27ecb0951086..4ac9bc86787a 100644
--- a/products/ai_observability/frontend/feedback-view/feedbackViewLogic.ts
+++ b/products/ai_observability/frontend/feedback-view/feedbackViewLogic.ts
@@ -5,9 +5,9 @@ import { subscriptions } from 'kea-subscriptions'
import api from 'lib/api'
import { dayjs } from 'lib/dayjs'
import { isUUIDLike } from 'lib/utils/guards'
+import { hogql } from 'lib/utils/hogql'
import { LLMTrace, LLMTraceEvent } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { Survey } from '~/types'
import { aiObservabilityTraceDataLogic } from '../aiObservabilityTraceDataLogic'
diff --git a/products/ai_observability/frontend/llmSessionTitleLazyLoaderLogic.ts b/products/ai_observability/frontend/llmSessionTitleLazyLoaderLogic.ts
index 647ed35cba77..b6f1e17ca4f9 100644
--- a/products/ai_observability/frontend/llmSessionTitleLazyLoaderLogic.ts
+++ b/products/ai_observability/frontend/llmSessionTitleLazyLoaderLogic.ts
@@ -2,9 +2,9 @@ import { MakeLogicType, actions, events, kea, listeners, path, reducers, selecto
import api from 'lib/api'
import { chunk } from 'lib/utils/arrays'
+import { escapeHogQLString } from 'lib/utils/hogql'
import { HogQLQuery, NodeKind } from '~/queries/schema/schema-general'
-import { escapeHogQLString } from '~/queries/utils'
import { resolveTitleFromInputs } from './sessionTitle'
import type { DateRangeFilter } from './types'
diff --git a/products/ai_observability/frontend/sentimentQueries.ts b/products/ai_observability/frontend/sentimentQueries.ts
index f02d4334f25a..abcd3deab41c 100644
--- a/products/ai_observability/frontend/sentimentQueries.ts
+++ b/products/ai_observability/frontend/sentimentQueries.ts
@@ -1,7 +1,7 @@
import api from 'lib/api'
+import { escapeHogQLString, hogql } from 'lib/utils/hogql'
import { ProductKey, type RefreshType } from '~/queries/schema/schema-general'
-import { escapeHogQLString, hogql } from '~/queries/utils'
import { normalizeSentimentResult, type GenerationSentiment } from './sentimentResults'
diff --git a/products/ai_observability/frontend/tags/llmTaggerLogic.ts b/products/ai_observability/frontend/tags/llmTaggerLogic.ts
index 41461ffc3a18..c93ee9b8455e 100644
--- a/products/ai_observability/frontend/tags/llmTaggerLogic.ts
+++ b/products/ai_observability/frontend/tags/llmTaggerLogic.ts
@@ -5,11 +5,11 @@ import { router } from 'kea-router'
import api from 'lib/api'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { escapeHogQLString } from 'lib/utils/hogql'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { HogQLQuery, NodeKind, TrendsQuery } from '~/queries/schema/schema-general'
-import { escapeHogQLString } from '~/queries/utils'
import { ChartDisplayType, PropertyFilterType, PropertyOperator } from '~/types'
import { aiObservabilitySharedLogic } from '../aiObservabilitySharedLogic'
diff --git a/products/ai_observability/frontend/traceMessagesLazyLoaderLogic.ts b/products/ai_observability/frontend/traceMessagesLazyLoaderLogic.ts
index bf5aac43bc4c..65a117e90b12 100644
--- a/products/ai_observability/frontend/traceMessagesLazyLoaderLogic.ts
+++ b/products/ai_observability/frontend/traceMessagesLazyLoaderLogic.ts
@@ -2,9 +2,9 @@ import { MakeLogicType, actions, events, kea, listeners, path, reducers, selecto
import api from 'lib/api'
import { chunk } from 'lib/utils/arrays'
+import { escapeHogQLString } from 'lib/utils/hogql'
import { HogQLQuery, NodeKind } from '~/queries/schema/schema-general'
-import { escapeHogQLString } from '~/queries/utils'
import { parsePartialJSON } from './utils'
diff --git a/products/ai_observability/frontend/utils.ts b/products/ai_observability/frontend/utils.ts
index c2459fd02757..f2ccf8849a1e 100644
--- a/products/ai_observability/frontend/utils.ts
+++ b/products/ai_observability/frontend/utils.ts
@@ -3,9 +3,9 @@ import * as PartialJSON from 'partial-json'
import api from 'lib/api'
import { dayjs } from 'lib/dayjs'
import { isObject, isString } from 'lib/utils/guards'
+import { escapeHogQLString, hogql } from 'lib/utils/hogql'
import { DateRange, LLMTrace, LLMTraceEvent } from '~/queries/schema/schema-general'
-import { escapeHogQLString, hogql } from '~/queries/utils'
import type { SpanAggregation } from './aiObservabilityTraceDataLogic'
import {
diff --git a/products/ai_observability/frontend/utils/aiEvents.ts b/products/ai_observability/frontend/utils/aiEvents.ts
index c9d12527f4c5..82f9db9dbcd3 100644
--- a/products/ai_observability/frontend/utils/aiEvents.ts
+++ b/products/ai_observability/frontend/utils/aiEvents.ts
@@ -1,8 +1,8 @@
import api from 'lib/api'
import { isDefinitionStale } from 'lib/utils/definitions'
+import { hogql } from 'lib/utils/hogql'
import { HogQLQuery, NodeKind, ProductKey } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { EventDefinitionType } from '~/types'
// Keep in sync with the `setupProbe` in ../../manifest.tsx (the boot-time approximation of this check).
diff --git a/products/autoresearch/frontend/autoresearchPipelineLogic.ts b/products/autoresearch/frontend/autoresearchPipelineLogic.ts
index 685b0012a71c..104fc29b3175 100644
--- a/products/autoresearch/frontend/autoresearchPipelineLogic.ts
+++ b/products/autoresearch/frontend/autoresearchPipelineLogic.ts
@@ -8,12 +8,12 @@ import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
import { lemonToast } from 'lib/lemon-ui/LemonToast'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { hogql } from 'lib/utils/hogql'
import { projectLogic } from 'scenes/projectLogic'
import { Scene } from 'scenes/sceneTypes'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
-import { hogql } from '~/queries/utils'
import { Breadcrumb } from '~/types'
import { cohortsCreate } from 'products/cohorts/frontend/generated/api'
diff --git a/products/autoresearch/frontend/predictionSegments.ts b/products/autoresearch/frontend/predictionSegments.ts
index d968f04ca979..b631e8c2412b 100644
--- a/products/autoresearch/frontend/predictionSegments.ts
+++ b/products/autoresearch/frontend/predictionSegments.ts
@@ -1,10 +1,10 @@
import { combineUrl } from 'kea-router'
+import { escapePropertyAsHogQLIdentifier } from 'lib/utils/hogql'
import { urls } from 'scenes/urls'
import { defaultDataTableColumns } from '~/queries/nodes/DataTable/utils'
import { DataTableNode, InsightVizNode, NodeKind } from '~/queries/schema/schema-general'
-import { escapePropertyAsHogQLIdentifier } from '~/queries/utils'
import { BaseMathType, PersonPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
import type { CohortFiltersApi, PersonFilterApi } from 'products/cohorts/frontend/generated/api.schemas'
diff --git a/products/business_intelligence/frontend/BICalculatedMeasureModal.tsx b/products/business_intelligence/frontend/BICalculatedMeasureModal.tsx
index 1ef8b2eac38d..1e9494d4fd26 100644
--- a/products/business_intelligence/frontend/BICalculatedMeasureModal.tsx
+++ b/products/business_intelligence/frontend/BICalculatedMeasureModal.tsx
@@ -3,9 +3,9 @@ import { useActions, useValues } from 'kea'
import { LemonButton, LemonInput, LemonLabel, LemonModal, LemonSelect } from '@posthog/lemon-ui'
import { CodeEditorInline } from 'lib/monaco/CodeEditorInline'
+import { escapeDottedHogQLIdentifier } from 'lib/utils/hogql'
import { NodeKind } from '~/queries/schema/schema-general'
-import { escapeDottedHogQLIdentifier } from '~/queries/utils'
import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
diff --git a/products/business_intelligence/frontend/biAnalysis.ts b/products/business_intelligence/frontend/biAnalysis.ts
index 7d46877247be..812d5083d3bf 100644
--- a/products/business_intelligence/frontend/biAnalysis.ts
+++ b/products/business_intelligence/frontend/biAnalysis.ts
@@ -1,5 +1,6 @@
+import { escapeHogQLString, escapeRawPropertyAsHogQLIdentifier } from 'lib/utils/hogql'
+
import { BIConfig, BIField, BITableCalculation, BIValue } from '~/queries/schema/schema-business-intelligence'
-import { escapeHogQLString, escapeRawPropertyAsHogQLIdentifier } from '~/queries/utils'
import { ChartDisplayType } from '~/types'
import { biComparisonSeries } from './biComparison'
diff --git a/products/business_intelligence/frontend/biComparison.ts b/products/business_intelligence/frontend/biComparison.ts
index d559ab99541c..1344ab78b959 100644
--- a/products/business_intelligence/frontend/biComparison.ts
+++ b/products/business_intelligence/frontend/biComparison.ts
@@ -1,5 +1,6 @@
+import { escapeHogQLString } from 'lib/utils/hogql'
+
import { BIConfig, BIField } from '~/queries/schema/schema-business-intelligence'
-import { escapeHogQLString } from '~/queries/utils'
import { ChartDisplayType } from '~/types'
import { getBIDateField } from './biQueryFilters'
diff --git a/products/business_intelligence/frontend/biComparisonLimit.ts b/products/business_intelligence/frontend/biComparisonLimit.ts
index 5a8782e8d198..18dd6dccc1e1 100644
--- a/products/business_intelligence/frontend/biComparisonLimit.ts
+++ b/products/business_intelligence/frontend/biComparisonLimit.ts
@@ -1,5 +1,6 @@
+import { escapeRawPropertyAsHogQLIdentifier } from 'lib/utils/hogql'
+
import { BIConfig } from '~/queries/schema/schema-business-intelligence'
-import { escapeRawPropertyAsHogQLIdentifier } from '~/queries/utils'
export function getBIComparisonGroupLimit(config: BIConfig): number {
// Keep room for both periods without exceeding the backend's row cap.
diff --git a/products/business_intelligence/frontend/biDrilldown.ts b/products/business_intelligence/frontend/biDrilldown.ts
index ebc690b8f628..32f3d4491278 100644
--- a/products/business_intelligence/frontend/biDrilldown.ts
+++ b/products/business_intelligence/frontend/biDrilldown.ts
@@ -1,4 +1,5 @@
import { dayjs } from 'lib/dayjs'
+import { escapeHogQLString } from 'lib/utils/hogql'
import { BIConfig, BIFilter, BIVisualizationNode } from '~/queries/schema/schema-business-intelligence'
import {
@@ -8,7 +9,6 @@ import {
VisualizationNode,
NodeKind,
} from '~/queries/schema/schema-general'
-import { escapeHogQLString } from '~/queries/utils'
import { ChartDisplayType } from '~/types'
import { decodeBIComparisonCategory, decodeBIComparisonSeries, getBIComparisonDateExpression } from './biComparison'
diff --git a/products/business_intelligence/frontend/biEditorLogic.ts b/products/business_intelligence/frontend/biEditorLogic.ts
index d6873b4bfd0a..9c108160f9b9 100644
--- a/products/business_intelligence/frontend/biEditorLogic.ts
+++ b/products/business_intelligence/frontend/biEditorLogic.ts
@@ -3,6 +3,7 @@ import { loaders } from 'kea-loaders'
import { subscriptions } from 'kea-subscriptions'
import { uuid } from 'lib/utils/dom'
+import { escapeDottedHogQLIdentifier } from 'lib/utils/hogql'
import { TableFieldsStatus, databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
import { performQuery } from '~/queries/query'
@@ -34,7 +35,6 @@ import {
HogLanguage,
NodeKind,
} from '~/queries/schema/schema-general'
-import { escapeDottedHogQLIdentifier } from '~/queries/utils'
import { ChartDisplayType } from '~/types'
import {
diff --git a/products/business_intelligence/frontend/biEditorTypes.ts b/products/business_intelligence/frontend/biEditorTypes.ts
index f1fdbe700f9e..263dce214247 100644
--- a/products/business_intelligence/frontend/biEditorTypes.ts
+++ b/products/business_intelligence/frontend/biEditorTypes.ts
@@ -1,4 +1,10 @@
import { dayjs } from 'lib/dayjs'
+import {
+ escapeDottedHogQLIdentifier,
+ escapeHogQLString,
+ escapePropertyAsHogQLIdentifier,
+ escapeRawPropertyAsHogQLIdentifier,
+} from 'lib/utils/hogql'
import { getAutoBoxPlotSettings } from '~/queries/nodes/DataVisualization/Components/Charts/sqlBoxPlotAdapter'
import {
@@ -22,12 +28,6 @@ import {
HogQLQuery,
NodeKind,
} from '~/queries/schema/schema-general'
-import {
- escapeDottedHogQLIdentifier,
- escapeHogQLString,
- escapePropertyAsHogQLIdentifier,
- escapeRawPropertyAsHogQLIdentifier,
-} from '~/queries/utils'
import { ChartDisplayType } from '~/types'
import {
diff --git a/products/business_intelligence/frontend/biFilterValuesLogic.ts b/products/business_intelligence/frontend/biFilterValuesLogic.ts
index b9e5aa9b3e1b..697c8a8f5751 100644
--- a/products/business_intelligence/frontend/biFilterValuesLogic.ts
+++ b/products/business_intelligence/frontend/biFilterValuesLogic.ts
@@ -15,11 +15,11 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { uuid } from 'lib/utils/dom'
+import { escapeHogQLString } from 'lib/utils/hogql'
import { performQuery } from '~/queries/query'
import { BIConfig } from '~/queries/schema/schema-business-intelligence'
import { HogQLQuery } from '~/queries/schema/schema-general'
-import { escapeHogQLString } from '~/queries/utils'
import { captureBIWorksheetAction } from './biEditorAnalytics'
diff --git a/products/business_intelligence/frontend/biJoinKeyCheck.ts b/products/business_intelligence/frontend/biJoinKeyCheck.ts
index 9c6463fb706f..fb5b3d0b1384 100644
--- a/products/business_intelligence/frontend/biJoinKeyCheck.ts
+++ b/products/business_intelligence/frontend/biJoinKeyCheck.ts
@@ -1,4 +1,5 @@
-import { escapeRawPropertyAsHogQLIdentifier } from '~/queries/utils'
+import { escapeRawPropertyAsHogQLIdentifier } from 'lib/utils/hogql'
+
import { DataWarehouseViewLink } from '~/types'
const fieldIdentifier =
diff --git a/products/business_intelligence/frontend/biLocalFields.ts b/products/business_intelligence/frontend/biLocalFields.ts
index cdce6d6cff3c..742a8db9353b 100644
--- a/products/business_intelligence/frontend/biLocalFields.ts
+++ b/products/business_intelligence/frontend/biLocalFields.ts
@@ -1,5 +1,6 @@
+import { escapeHogQLString } from 'lib/utils/hogql'
+
import { BIConfig, BIField, BILocalFieldDefinition } from '~/queries/schema/schema-business-intelligence'
-import { escapeHogQLString } from '~/queries/utils'
export function localFieldError(definition: BILocalFieldDefinition): string | undefined {
if (!definition || typeof definition.expression !== 'string' || !definition.expression.trim()) {
diff --git a/products/business_intelligence/frontend/biPropertyFields.ts b/products/business_intelligence/frontend/biPropertyFields.ts
index 5a7939e50fd2..b2ab734f6b6b 100644
--- a/products/business_intelligence/frontend/biPropertyFields.ts
+++ b/products/business_intelligence/frontend/biPropertyFields.ts
@@ -1,6 +1,7 @@
+import { escapeRawPropertyAsHogQLIdentifier } from 'lib/utils/hogql'
+
import { EnterprisePropertyDefinitionApi } from '~/generated/core/api.schemas'
import { BIField } from '~/queries/schema/schema-business-intelligence'
-import { escapeRawPropertyAsHogQLIdentifier } from '~/queries/utils'
import {
getSidebarPropertyDefinitionTarget,
diff --git a/products/business_intelligence/frontend/biQueryFilters.ts b/products/business_intelligence/frontend/biQueryFilters.ts
index fb987275f2be..1319f042fbd5 100644
--- a/products/business_intelligence/frontend/biQueryFilters.ts
+++ b/products/business_intelligence/frontend/biQueryFilters.ts
@@ -1,6 +1,7 @@
+import { escapeHogQLString } from 'lib/utils/hogql'
+
import { BIConfig, BIDataSource, BIField } from '~/queries/schema/schema-business-intelligence'
import { DateRange, HogQLFilters, HogQLQuery } from '~/queries/schema/schema-general'
-import { escapeHogQLString } from '~/queries/utils'
const NATIVE_DATE_FIELDS: Record<string, string> = {
events: 'timestamp',
diff --git a/products/business_intelligence/frontend/biTimeSeries.ts b/products/business_intelligence/frontend/biTimeSeries.ts
index de8427b3656b..5d0b2909bb25 100644
--- a/products/business_intelligence/frontend/biTimeSeries.ts
+++ b/products/business_intelligence/frontend/biTimeSeries.ts
@@ -1,8 +1,8 @@
import { dayjs } from 'lib/dayjs'
import { dateStringToDayJs } from 'lib/utils/dateFilters'
+import { escapeRawPropertyAsHogQLIdentifier } from 'lib/utils/hogql'
import { BIConfig, BIDateBucket } from '~/queries/schema/schema-business-intelligence'
-import { escapeRawPropertyAsHogQLIdentifier } from '~/queries/utils'
import { ChartDisplayType } from '~/types'
import type { BIAnalysisInput } from './biAnalysis'
diff --git a/products/business_intelligence/frontend/components/BIExpressionPopover.tsx b/products/business_intelligence/frontend/components/BIExpressionPopover.tsx
index 597e668e935d..10197345db64 100644
--- a/products/business_intelligence/frontend/components/BIExpressionPopover.tsx
+++ b/products/business_intelligence/frontend/components/BIExpressionPopover.tsx
@@ -4,10 +4,10 @@ import { IconX } from '@posthog/icons'
import { LemonButton, LemonDropdown, LemonSelect } from '@posthog/lemon-ui'
import { HogQLEditor } from 'lib/components/HogQLEditor/HogQLEditor'
+import { escapeDottedHogQLIdentifier } from 'lib/utils/hogql'
import { BIAggregation, BIDataSource } from '~/queries/schema/schema-business-intelligence'
import { NodeKind } from '~/queries/schema/schema-general'
-import { escapeDottedHogQLIdentifier } from '~/queries/utils'
import { AGGREGATION_OPTIONS } from '../biEditorOptions'
diff --git a/products/canvas/frontend/sidePanel/blocks/inspector/canvasBlockPickersLogic.ts b/products/canvas/frontend/sidePanel/blocks/inspector/canvasBlockPickersLogic.ts
index 4a85d17004c1..2008160b3eb5 100644
--- a/products/canvas/frontend/sidePanel/blocks/inspector/canvasBlockPickersLogic.ts
+++ b/products/canvas/frontend/sidePanel/blocks/inspector/canvasBlockPickersLogic.ts
@@ -2,10 +2,9 @@ import { MakeLogicType, actions, connect, kea, listeners, path, reducers } from
import { loaders } from 'kea-loaders'
import api from 'lib/api'
+import { hogql } from 'lib/utils/hogql'
import { projectLogic } from 'scenes/projectLogic'
-import { hogql } from '~/queries/utils'
-
import { insightsList } from 'products/product_analytics/frontend/generated/api'
// The same lookups PostHog Desktop's block pickers run: the most common events and property keys, by volume.
diff --git a/products/customer_analytics/frontend/components/Accounts/accountOpportunitiesLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountOpportunitiesLogic.ts
index 63caf90e2e9e..06da32d23f3d 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountOpportunitiesLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountOpportunitiesLogic.ts
@@ -3,10 +3,10 @@ import { loaders } from 'kea-loaders'
import posthog from 'posthog-js'
import api from 'lib/api'
+import { hogql } from 'lib/utils/hogql'
import { teamLogic } from 'scenes/teamLogic'
import { HogQLQueryResponse, NodeKind } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { accountsRetrieve } from 'products/customer_analytics/frontend/generated/api'
diff --git a/products/customer_analytics/frontend/components/Accounts/accountRelatedUsersLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountRelatedUsersLogic.ts
index fe54635c870b..95818ee7c9be 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountRelatedUsersLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountRelatedUsersLogic.ts
@@ -19,9 +19,9 @@ import { Sorting } from '@posthog/lemon-ui'
import api, { CountedPaginatedResponse } from 'lib/api'
import { OrganizationMembershipLevel } from 'lib/constants'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { hogql } from 'lib/utils/hogql'
import { HogQLQueryResponse, NodeKind } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { OrganizationMemberType, Region } from '~/types'
import { CUSTOMER_ANALYTICS_DEFAULT_QUERY_TAGS } from '../../constants'
diff --git a/products/customer_analytics/frontend/components/Accounts/billingUsageQuery.ts b/products/customer_analytics/frontend/components/Accounts/billingUsageQuery.ts
index 77ce45d8b322..1afce89a0628 100644
--- a/products/customer_analytics/frontend/components/Accounts/billingUsageQuery.ts
+++ b/products/customer_analytics/frontend/components/Accounts/billingUsageQuery.ts
@@ -1,5 +1,6 @@
+import { escapeRawPropertyAsHogQLIdentifier } from 'lib/utils/hogql'
+
import { DataVisualizationNode, NodeKind } from '~/queries/schema/schema-general'
-import { escapeRawPropertyAsHogQLIdentifier } from '~/queries/utils'
import { ChartDisplayType } from '~/types'
export type BillingUsageInterval = 'day' | 'week' | 'month'
diff --git a/products/customer_analytics/frontend/queries/ZendeskTicketsQuery.tsx b/products/customer_analytics/frontend/queries/ZendeskTicketsQuery.tsx
index 4b6e77b2e86b..58356639f6b5 100644
--- a/products/customer_analytics/frontend/queries/ZendeskTicketsQuery.tsx
+++ b/products/customer_analytics/frontend/queries/ZendeskTicketsQuery.tsx
@@ -1,8 +1,9 @@
import { Link } from '@posthog/lemon-ui'
+import { hogql } from 'lib/utils/hogql'
+
import { DataTableNode, NodeKind } from '~/queries/schema/schema-general'
import { QueryContext, QueryContextColumn } from '~/queries/types'
-import { hogql } from '~/queries/utils'
import { CUSTOMER_ANALYTICS_DEFAULT_QUERY_TAGS } from '../constants'
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts
index 25417f85c5fc..ad5a41b901d1 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts
@@ -6,11 +6,11 @@ import posthog from 'posthog-js'
import api from 'lib/api'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { hogql } from 'lib/utils/hogql'
import { projectLogic } from 'scenes/projectLogic'
import { urls } from 'scenes/urls'
import { HogQLQueryResponse, NodeKind } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import type { DataWarehouseSavedQuery, DataWarehouseTable, PropertyDefinition } from '~/types'
import { PropertyDefinitionType } from '~/types'
diff --git a/products/data_quality/frontend/CheckEditorModal.tsx b/products/data_quality/frontend/CheckEditorModal.tsx
index 8453057f0c93..fe3628569879 100644
--- a/products/data_quality/frontend/CheckEditorModal.tsx
+++ b/products/data_quality/frontend/CheckEditorModal.tsx
@@ -20,10 +20,9 @@ import { LemonField } from 'lib/lemon-ui/LemonField'
import { LemonTable, LemonTableColumns } from 'lib/lemon-ui/LemonTable'
import type { CodeEditorProps } from 'lib/monaco/CodeEditor'
import { CodeEditorResizeable } from 'lib/monaco/CodeEditorResizable'
+import { escapePropertyAsHogQLIdentifier } from 'lib/utils/hogql'
import { urls } from 'scenes/urls'
-import { escapePropertyAsHogQLIdentifier } from '~/queries/utils'
-
import type { DataQualitySubjectRef } from './checksApi'
import { checkTypeLabel, subjectTypeLabel } from './checksConstants'
import { dataQualityCheckEditorLogic } from './dataQualityCheckEditorLogic'
diff --git a/products/data_warehouse/frontend/utils.ts b/products/data_warehouse/frontend/utils.ts
index 8afd5c6a3ad4..94e93758cd7b 100644
--- a/products/data_warehouse/frontend/utils.ts
+++ b/products/data_warehouse/frontend/utils.ts
@@ -1,9 +1,9 @@
import { LemonTagType } from '@posthog/lemon-ui'
+import { escapeDottedHogQLIdentifier } from 'lib/utils/hogql'
import { urls } from 'scenes/urls'
import { DataVisualizationNode, DatabaseSchemaField, NodeKind } from '~/queries/schema/schema-general'
-import { escapeDottedHogQLIdentifier } from '~/queries/utils'
import {
DataModelingSyncInterval,
DataWarehouseSyncInterval,
diff --git a/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts
index 2ad8307d9589..1254749791a3 100644
--- a/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts
+++ b/products/error_tracking/frontend/components/SuppressSimilarIssues/suppressSimilarIssuesLogic.ts
@@ -5,12 +5,12 @@ import posthog from 'posthog-js'
import api from 'lib/api'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { hogql } from 'lib/utils/hogql'
import { pluralize } from 'lib/utils/strings'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { EventsQuery, NodeKind, ProductKey } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { PropertyGroupFilterValue } from '~/types'
import { errorTrackingSuppressionRulesCreate } from '../../generated/api'
diff --git a/products/error_tracking/frontend/queries.ts b/products/error_tracking/frontend/queries.ts
index e8df84cc87d9..ba694c1dbecd 100644
--- a/products/error_tracking/frontend/queries.ts
+++ b/products/error_tracking/frontend/queries.ts
@@ -1,4 +1,5 @@
import { isUniversalGroupFilterLike } from 'lib/components/UniversalFilters/utils'
+import { HogQLQueryString, escapeHogQLString, hogql } from 'lib/utils/hogql'
import {
DataTableNode,
@@ -17,7 +18,7 @@ import {
NodeKind,
ProductKey,
} from '~/queries/schema/schema-general'
-import { HogQLQueryString, escapeHogQLString, hogql, setLatestVersionsOnQuery } from '~/queries/utils'
+import { setLatestVersionsOnQuery } from '~/queries/utils'
import {
AnyPropertyFilter,
BaseMathType,
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/issueAffectedBroadcastLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/issueAffectedBroadcastLogic.ts
index cb1d42cd9c8c..2487be4d0f6e 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/issueAffectedBroadcastLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/issueAffectedBroadcastLogic.ts
@@ -4,12 +4,12 @@ import { router } from 'kea-router'
import { lemonToast } from '@posthog/lemon-ui'
+import { HogQLQueryString, hogql } from 'lib/utils/hogql'
import { pluralize, truncate } from 'lib/utils/strings'
import { teamLogic } from 'scenes/teamLogic'
import { hogqlQuery } from '~/queries/query'
import { NodeKind } from '~/queries/schema/schema-general'
-import { HogQLQueryString, hogql } from '~/queries/utils'
import { cohortsCreate } from 'products/cohorts/frontend/generated/api'
import type { CohortApi } from 'products/cohorts/frontend/generated/api.schemas'
diff --git a/products/error_tracking/frontend/utils.ts b/products/error_tracking/frontend/utils.ts
index c2c7dd5d8230..053e544f7443 100644
--- a/products/error_tracking/frontend/utils.ts
+++ b/products/error_tracking/frontend/utils.ts
@@ -7,11 +7,11 @@ import { ErrorTrackingException } from 'lib/components/Errors/types'
import { Dayjs, dayjs } from 'lib/dayjs'
import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { componentsToDayJs, dateStringToComponents, dateStringToDayJs, isStringDateRegex } from 'lib/utils/dateFilters'
+import { escapeHogQLString } from 'lib/utils/hogql'
import { Params } from 'scenes/sceneTypes'
import { convertUniversalFiltersToRecordingsQuery } from 'scenes/session-recordings/filters/recordingsQueryConversions'
import { DateRange, ErrorTrackingIssue } from '~/queries/schema/schema-general'
-import { escapeHogQLString } from '~/queries/utils'
import {
AccessControlLevel,
AccessControlResourceType,
diff --git a/products/logs/frontend/components/LogsSampling/samplingRuleDropImpact.ts b/products/logs/frontend/components/LogsSampling/samplingRuleDropImpact.ts
index b8975fe3d720..0e0c66a3eddf 100644
--- a/products/logs/frontend/components/LogsSampling/samplingRuleDropImpact.ts
+++ b/products/logs/frontend/components/LogsSampling/samplingRuleDropImpact.ts
@@ -1,6 +1,5 @@
import api from 'lib/api'
-
-import { type HogQLQueryString, hogql } from '~/queries/utils'
+import { type HogQLQueryString, hogql } from 'lib/utils/hogql'
export interface SamplingRuleDropTotals {
records: number
diff --git a/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.ts b/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.ts
index 6b4c4ce3bf6d..2ff4ca7dba27 100644
--- a/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.ts
+++ b/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.ts
@@ -5,8 +5,7 @@ import api from 'lib/api'
import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
import { type FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
-
-import { hogql } from '~/queries/utils'
+import { hogql } from 'lib/utils/hogql'
import { logsViewerDataLogic } from 'products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic'
import { logsConfigLogic } from 'products/logs/frontend/logsConfigLogic'
diff --git a/products/marketing_analytics/frontend/search/searchPerformance.ts b/products/marketing_analytics/frontend/search/searchPerformance.ts
index 43f4bd04a23b..8156831c7141 100644
--- a/products/marketing_analytics/frontend/search/searchPerformance.ts
+++ b/products/marketing_analytics/frontend/search/searchPerformance.ts
@@ -1,11 +1,11 @@
import { dayjs } from 'lib/dayjs'
+import { HogQLQueryString, escapePropertyAsHogQLIdentifier, hogql } from 'lib/utils/hogql'
import {
MarketingAnalyticsSearchQuery,
MarketingAnalyticsSearchSource,
MarketingAnalyticsSearchRow,
} from '~/queries/schema/schema-general'
-import { HogQLQueryString, escapePropertyAsHogQLIdentifier, hogql } from '~/queries/utils'
import { ExternalDataSchemaStatus, ExternalDataSource, ExternalDataSourceSchema } from '~/types'
export type SearchPlatform = MarketingAnalyticsSearchSource['sourceType']
diff --git a/products/mcp_analytics/frontend/components/toolCallFeedQuery.ts b/products/mcp_analytics/frontend/components/toolCallFeedQuery.ts
index 774213695ab1..f0730e935f2d 100644
--- a/products/mcp_analytics/frontend/components/toolCallFeedQuery.ts
+++ b/products/mcp_analytics/frontend/components/toolCallFeedQuery.ts
@@ -1,9 +1,9 @@
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { MCP_TOOL_CALL_EVENT } from 'lib/components/TaxonomicFilter/utils/mcpProperties'
+import { hogql } from 'lib/utils/hogql'
import { pageCollectionId } from '~/queries/nodes/DataNode/pageCollections'
import { DataTableNode, HogQLFilters, NodeKind } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
import { LAB_ORDER, labSqlExpression } from '../aiLabs'
diff --git a/products/notebooks/frontend/ReusableWidgetPicker/reusableWidgetMapping.ts b/products/notebooks/frontend/ReusableWidgetPicker/reusableWidgetMapping.ts
index bb2fcca762c8..67dea5d64b35 100644
--- a/products/notebooks/frontend/ReusableWidgetPicker/reusableWidgetMapping.ts
+++ b/products/notebooks/frontend/ReusableWidgetPicker/reusableWidgetMapping.ts
@@ -1,7 +1,6 @@
+import { escapeHogQLString } from 'lib/utils/hogql'
import type { NotebookFrameNodeSummary } from 'scenes/notebooks/Nodes/notebookNodeContent'
-import { escapeHogQLString } from '~/queries/utils'
-
import type { WidgetInputContractColumnApi } from '../generated/api.schemas'
export function widgetInputMatches(columns: WidgetInputContractColumnApi[], frame: NotebookFrameNodeSummary): boolean {
diff --git a/products/persons/frontend/logics/personLogic.tsx b/products/persons/frontend/logics/personLogic.tsx
index 25da7ce6c48d..926653ad0f4f 100644
--- a/products/persons/frontend/logics/personLogic.tsx
+++ b/products/persons/frontend/logics/personLogic.tsx
@@ -3,11 +3,11 @@ import { lazyLoaders } from 'kea-loaders'
import posthog from 'posthog-js'
import api from 'lib/api'
+import { hogql } from 'lib/utils/hogql'
import { sceneConfigurations } from 'scenes/scenes'
import { Scene } from 'scenes/sceneTypes'
import { HogQLQuery, NodeKind } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { Breadcrumb, PersonType } from '~/types'
import { CUSTOMER_ANALYTICS_DEFAULT_QUERY_TAGS } from 'products/customer_analytics/frontend/constants'
diff --git a/products/persons/frontend/person-utils.ts b/products/persons/frontend/person-utils.ts
index b328049643ce..7ac338de89d3 100644
--- a/products/persons/frontend/person-utils.ts
+++ b/products/persons/frontend/person-utils.ts
@@ -4,11 +4,11 @@ import { PERSON_DEFAULT_DISPLAY_NAME_PROPERTIES } from 'lib/constants'
import { NUM_LETTERMARK_STYLES } from 'lib/lemon-ui/Lettermark/Lettermark'
import { ProfilePictureProps } from 'lib/lemon-ui/ProfilePicture'
import { isUUIDLike } from 'lib/utils/guards'
+import { HogQLQueryString, hogql } from 'lib/utils/hogql'
import { midEllipsis } from 'lib/utils/strings'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
-import { HogQLQueryString, hogql } from '~/queries/utils'
import { PersonType } from '~/types'
/**
diff --git a/products/product_analytics/frontend/insights/dataChecks/repeatedEventsQuery.ts b/products/product_analytics/frontend/insights/dataChecks/repeatedEventsQuery.ts
index 447ecbade764..9709c7320354 100644
--- a/products/product_analytics/frontend/insights/dataChecks/repeatedEventsQuery.ts
+++ b/products/product_analytics/frontend/insights/dataChecks/repeatedEventsQuery.ts
@@ -1,4 +1,4 @@
-import { hogql } from '~/queries/utils'
+import { hogql } from 'lib/utils/hogql'
// Matches the check's window on the server, so the query lists the same repeats the check counted.
export const REPEAT_WINDOW_MILLISECONDS = 100
diff --git a/products/product_analytics/frontend/insights/editor/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx b/products/product_analytics/frontend/insights/editor/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx
index 69e94ddd149c..003431c0f775 100644
--- a/products/product_analytics/frontend/insights/editor/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx
+++ b/products/product_analytics/frontend/insights/editor/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx
@@ -3,6 +3,7 @@ import { useActions, useMountedLogic, useValues } from 'kea'
import { TaxonomicFilter } from 'lib/components/TaxonomicFilter/TaxonomicFilter'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { Popover } from 'lib/lemon-ui/Popover/Popover'
+import { hogql } from 'lib/utils/hogql'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
import { insightLogic } from 'scenes/insights/insightLogic'
import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
@@ -10,7 +11,7 @@ import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
import { actionsModel } from '~/models/actionsModel'
import { groupsModel } from '~/models/groupsModel'
import { NodeKind } from '~/queries/schema/schema-general'
-import { hogql, isActionsNode, isInsightQueryWithSeries, isInsightVizNode, isRetentionQuery } from '~/queries/utils'
+import { isActionsNode, isInsightQueryWithSeries, isInsightVizNode, isRetentionQuery } from '~/queries/utils'
import { taxonomicBreakdownFilterLogic } from './taxonomicBreakdownFilterLogic'
diff --git a/products/replay_vision/frontend/observations/observationSessionPropertiesLogic.ts b/products/replay_vision/frontend/observations/observationSessionPropertiesLogic.ts
index 6ebf72152cc8..569cad63c1b0 100644
--- a/products/replay_vision/frontend/observations/observationSessionPropertiesLogic.ts
+++ b/products/replay_vision/frontend/observations/observationSessionPropertiesLogic.ts
@@ -3,10 +3,10 @@ import { loaders } from 'kea-loaders'
import posthog from 'posthog-js'
import api from 'lib/api'
+import { HogQLQueryString, escapePropertyAsHogQLIdentifier, hogql } from 'lib/utils/hogql'
import { getTimestampFromUUIDv7 } from 'scenes/sessions/sessionProfileLogic'
import { QueryLogTags } from '~/queries/schema/schema-general'
-import { HogQLQueryString, escapePropertyAsHogQLIdentifier, hogql } from '~/queries/utils'
import { PinnedProperty, observationPinnedPropertiesLogic } from './observationPinnedPropertiesLogic'
diff --git a/products/web_analytics/frontend/heatmaps/components/heatmapCoverageLogic.ts b/products/web_analytics/frontend/heatmaps/components/heatmapCoverageLogic.ts
index 778fc6de7800..6e7dd829cc75 100644
--- a/products/web_analytics/frontend/heatmaps/components/heatmapCoverageLogic.ts
+++ b/products/web_analytics/frontend/heatmaps/components/heatmapCoverageLogic.ts
@@ -6,10 +6,9 @@ import api from 'lib/api'
import { heatmapDataLogic } from 'lib/components/heatmaps/heatmapDataLogic'
import { hasWildcard, heatmapPageUrl, heatmapUrlPatternToRegex } from 'lib/components/heatmaps/heatmapUrlMatch'
import type { HeatmapKind } from 'lib/components/heatmaps/types'
+import { hogql } from 'lib/utils/hogql'
import { teamLogic } from 'scenes/teamLogic'
-import { hogql } from '~/queries/utils'
-
import type { HrefMatchType } from '../../../../../frontend/src/lib/components/heatmaps/heatmapDataLogic'
import type { HeatmapUrlMatchMode } from '../../../../../frontend/src/lib/components/heatmaps/heatmapUrlMatch'
import type { CommonFilters, HeatmapFilters } from '../../../../../frontend/src/lib/components/heatmaps/types'
diff --git a/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.ts b/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.ts
index 24973a2e8165..562012e6d2ed 100644
--- a/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.ts
+++ b/products/web_analytics/frontend/heatmaps/components/heatmapsBrowserLogic.ts
@@ -33,11 +33,10 @@ import { PostHogAppToolbarEvent, calculateViewportRange } from 'lib/components/I
import { FEATURE_FLAGS } from 'lib/constants'
import { LemonBannerProps } from 'lib/lemon-ui/LemonBanner'
import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { hogql } from 'lib/utils/hogql'
import { objectsEqual } from 'lib/utils/objects'
import { teamLogic } from 'scenes/teamLogic'
-import { hogql } from '~/queries/utils'
-
import { savedPreflightCreate } from 'products/web_analytics/frontend/generated/api'
import type { HeatmapPreflightResponseApi } from 'products/web_analytics/frontend/generated/api.schemas'
diff --git a/products/web_analytics/frontend/heatmaps/scenes/heatmap/heatmapCreationLogic.ts b/products/web_analytics/frontend/heatmaps/scenes/heatmap/heatmapCreationLogic.ts
index 6421b91e8455..1db6e680aeb1 100644
--- a/products/web_analytics/frontend/heatmaps/scenes/heatmap/heatmapCreationLogic.ts
+++ b/products/web_analytics/frontend/heatmaps/scenes/heatmap/heatmapCreationLogic.ts
@@ -25,12 +25,12 @@ import { FEATURE_FLAGS } from 'lib/constants'
import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
+import { hogql } from 'lib/utils/hogql'
import { sessionPlayerModalLogic } from 'scenes/session-recordings/player/modal/sessionPlayerModalLogic'
import type { SessionPlayerModalContext } from 'scenes/session-recordings/player/modal/sessionPlayerModalLogic'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
-import { hogql } from '~/queries/utils'
import { AccessControlLevel, AccessControlResourceType, HeatmapType } from '~/types'
import type { TeamPublicType, TeamType } from '~/types'
diff --git a/products/web_analytics/frontend/searchAndAi/searchAndAiQueries.ts b/products/web_analytics/frontend/searchAndAi/searchAndAiQueries.ts
index 9c92da3251a4..fd85ee7b3599 100644
--- a/products/web_analytics/frontend/searchAndAi/searchAndAiQueries.ts
+++ b/products/web_analytics/frontend/searchAndAi/searchAndAiQueries.ts
@@ -1,5 +1,6 @@
import { dayjs } from 'lib/dayjs'
import { componentsToDayJs, dateStringToComponents, dateStringToDayJs } from 'lib/utils/dateFilters'
+import { escapeDottedHogQLIdentifier, escapeHogQLString } from 'lib/utils/hogql'
import { percentage } from 'lib/utils/numbers'
import { BOT_ANALYTICS_EVENTS, WEB_ANALYTICS_DEFAULT_QUERY_TAGS } from 'scenes/web-analytics/common'
import type { DateFilterState } from 'scenes/web-analytics/webAnalyticsLogic'
@@ -20,7 +21,6 @@ import {
WebAnalyticsPropertyFilters,
WebStatsBreakdown,
} from '~/queries/schema/schema-general'
-import { escapeDottedHogQLIdentifier, escapeHogQLString } from '~/queries/utils'
import { BaseMathType, ChartDisplayType, FilterLogicalOperator, PropertyFilterType, PropertyOperator } from '~/types'
import type { AiAssistantRow } from './AiAssistantList'
diff --git a/products/workflows/frontend/Channels/EmailDomain/emailDomainWizardLogic.ts b/products/workflows/frontend/Channels/EmailDomain/emailDomainWizardLogic.ts
index d39358d59e22..585d58467cb2 100644
--- a/products/workflows/frontend/Channels/EmailDomain/emailDomainWizardLogic.ts
+++ b/products/workflows/frontend/Channels/EmailDomain/emailDomainWizardLogic.ts
@@ -5,13 +5,13 @@ import posthog from 'posthog-js'
import api, { ApiError } from 'lib/api'
import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import { preflightLogic } from 'lib/logic/preflightLogic'
+import { hogql } from 'lib/utils/hogql'
import { organizationLogic } from 'scenes/organizationLogic'
import { Scene } from 'scenes/sceneTypes'
import { teamLogic } from 'scenes/teamLogic'
import { userLogic } from 'scenes/userLogic'
import { ProductKey } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { IntegrationType, OrganizationType, PreflightStatus, TeamPublicType, TeamType, UserType } from '~/types'
import {
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorNotificationTestLogic.ts b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorNotificationTestLogic.ts
index 0a3e3623ea1b..24c16cb4fc46 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorNotificationTestLogic.ts
+++ b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorNotificationTestLogic.ts
@@ -8,10 +8,10 @@ import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
import { dayjs } from 'lib/dayjs'
import { uuid } from 'lib/utils/dom'
+import { hogql } from 'lib/utils/hogql'
import { performWideEventsQueryInTwoPhases } from 'scenes/hog-functions/sampleEventsQuery'
import { EventsQuery, NodeKind } from '~/queries/schema/schema-general'
-import { hogql } from '~/queries/utils'
import { CyclotronJobInvocationGlobals, FilterLogicalOperator, PersonType, PropertyFilterType } from '~/types'
import { WorkflowLogicProps, workflowLogic } from '../../../workflowLogic'
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts
index 311911cc69dc..0593c8a9a16b 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts
+++ b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts
@@ -23,6 +23,7 @@ import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
import { dayjs } from 'lib/dayjs'
import { groupsAccessLogic } from 'lib/introductions/groupsAccessLogic'
+import { escapePropertyAsHogQLIdentifier, hogql } from 'lib/utils/hogql'
import { FEATURE_FLAG_CALLED_EVENT } from 'scenes/feature-flags/flagEvaluationsTable'
import {
FLAG_CALLS_NOT_LOADABLE,
@@ -34,7 +35,6 @@ import { teamLogic } from 'scenes/teamLogic'
import { groupsModel } from '~/models/groupsModel'
import { EventsQuery, NodeKind } from '~/queries/schema/schema-general'
-import { escapePropertyAsHogQLIdentifier, hogql } from '~/queries/utils'
import {
AnyPropertyFilter,
CyclotronJobInvocationGlobals,
diff --git a/products/workflows/frontend/setupGuide/wizard/pushDeviceCheckLogic.ts b/products/workflows/frontend/setupGuide/wizard/pushDeviceCheckLogic.ts
index 413f5e1e422a..bd8bc28daeb9 100644
--- a/products/workflows/frontend/setupGuide/wizard/pushDeviceCheckLogic.ts
+++ b/products/workflows/frontend/setupGuide/wizard/pushDeviceCheckLogic.ts
@@ -5,8 +5,8 @@ import posthog from 'posthog-js'
import api from 'lib/api'
import { dayjs } from 'lib/dayjs'
import { integrationsLogic } from 'lib/integrations/integrationsLogic'
+import { hogql } from 'lib/utils/hogql'
-import { hogql } from '~/queries/utils'
import { IntegrationType } from '~/types'
export type PushPlatform = 'ios' | 'android'