Skip to content

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

fix(warehouse): hide managed connection for trino (#117369)

Eric Duong68f233c02ed5
diff --git a/docs/internal/managed-warehouse-sql-editor.md b/docs/internal/managed-warehouse-sql-editor.md
index e6647e8f5ca0..bb97239876bd 100644
--- a/docs/internal/managed-warehouse-sql-editor.md
+++ b/docs/internal/managed-warehouse-sql-editor.md
@@ -51,6 +51,8 @@ If Redis is unavailable, SQL editor queries and managed warehouse schema discove
The same `managed-warehouse-trino-query` organization feature flag adds **PostHog (Trino)** directly below **PostHog (ClickHouse)** in the SQL editor connection selector. The default PostHog target remains unchanged. The backend checks the same flag before execution and cache reads; selecting the target in a URL does not grant access.
+While this flag is enabled, the selector hides **PostHog (Managed warehouse)** from the menu so the built-in choices are ClickHouse and Trino. Existing queries that select the managed connection retain their connection ID, label and execution behavior. The managed option returns when the flag is disabled. Ordinary external connections remain visible.
+
Hosted Trino runs the current HogQL query through the Django-backed Trino compiler, preserving project scoping and the requesting user's table permissions. It resolves logical table names to the project's managed warehouse tables without requiring a stored model translation. Data must already exist in the Trino target; unsupported expressions and missing tables produce query errors. The target accepts HogQL only and cannot be combined with an external connection or raw SQL mode.
Each connection uses a short-lived hosted Trino service credential with a project/user principal. It does not read external-source passwords. Interactive queries retain a deadline and bounded result size, and asynchronous cancellation uses the existing direct-query cancellation token. Queries without an explicit limit use the existing SQL editor pagination and report whether more rows exist. SQL alerts use the same completeness probe as the default target. HTTP polling and prepared statements share the query deadline, and cursor cleanup makes one bounded cancellation attempt. Choosing another target preserves the query text, filters, and variables; the selection is saved with the query and editor URL.
diff --git a/frontend/src/scenes/data-warehouse/editor/connectionSelectorLogic.test.ts b/frontend/src/scenes/data-warehouse/editor/connectionSelectorLogic.test.ts
index 1b32e38ac85c..48e7b18cb7c9 100644
--- a/frontend/src/scenes/data-warehouse/editor/connectionSelectorLogic.test.ts
+++ b/frontend/src/scenes/data-warehouse/editor/connectionSelectorLogic.test.ts
@@ -1,5 +1,7 @@
import { expectLogic } from 'kea-test-utils'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { urls } from 'scenes/urls'
import { initKeaTests } from '~/test/init'
@@ -104,34 +106,45 @@ describe('connectionSelectorLogic', () => {
)
})
- it('shows a provisioned managed warehouse below ClickHouse', async () => {
- mockConnectionsList.mockResolvedValue([
- {
- id: 'conn-duck',
- prefix: 'managed_warehouse',
- engine: 'duckdb',
- source_type: 'Postgres',
- access_method: 'direct',
- supports_hogql: true,
- is_builtin_managed_warehouse: true,
- },
- ])
- logic = connectionSelectorLogic()
- logic.mount()
- logic.actions.maybeLoadConnectionOptions()
-
- await expectLogic(logic).toFinishAllListeners()
-
- const [clickHouseOption, managedWarehouseOption] = logic.values.connectionSelectOptions[0].options
- expect(clickHouseOption).toEqual(
- expect.objectContaining({ value: POSTHOG_WAREHOUSE, label: 'PostHog (ClickHouse)' })
- )
- expect(managedWarehouseOption).toEqual(
- expect.objectContaining({ value: 'conn-duck', label: 'PostHog (Managed warehouse)' })
- )
- expect(managedWarehouseOption.iconSrc).toEqual(clickHouseOption.iconSrc)
- expect(managedWarehouseOption).not.toHaveProperty('managementUrl')
- })
+ it.each([false, true])(
+ 'keeps the managed connection but hides its menu option with Trino enabled=%s',
+ async (enabled) => {
+ mockConnectionsList.mockResolvedValue([
+ {
+ id: 'conn-duck',
+ prefix: 'managed_warehouse',
+ engine: 'duckdb',
+ source_type: 'Postgres',
+ access_method: 'direct',
+ supports_hogql: true,
+ is_builtin_managed_warehouse: true,
+ },
+ ])
+ logic = connectionSelectorLogic()
+ logic.mount()
+ featureFlagLogic.actions.setFeatureFlags(enabled ? [FEATURE_FLAGS.MANAGED_TRINO_QUERY] : [], {
+ [FEATURE_FLAGS.MANAGED_TRINO_QUERY]: enabled,
+ })
+ logic.actions.maybeLoadConnectionOptions()
+
+ await expectLogic(logic).toFinishAllListeners()
+
+ const [clickHouseOption, managedWarehouseOption] = logic.values.connectionSelectOptions[0].options
+ expect(clickHouseOption).toEqual(
+ expect.objectContaining({ value: POSTHOG_WAREHOUSE, label: 'PostHog (ClickHouse)' })
+ )
+ expect(managedWarehouseOption).toEqual(
+ expect.objectContaining({ value: 'conn-duck', label: 'PostHog (Managed warehouse)', hidden: enabled })
+ )
+ expect(managedWarehouseOption.iconSrc).toEqual(clickHouseOption.iconSrc)
+ expect(managedWarehouseOption).not.toHaveProperty('managementUrl')
+ expect(logic.values.connectionOptions).toContainEqual(expect.objectContaining({ id: 'conn-duck' }))
+ expect(getConnectionSelectorValue(false, 'conn-duck')).toEqual('conn-duck')
+
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ expect(logic.values.connectionSelectOptions[0].options[1].hidden).toBe(false)
+ }
+ )
it('keeps the auto-provisioned Duckgres source external when the backend marks it external', async () => {
mockConnectionsList.mockResolvedValue([
@@ -148,6 +161,9 @@ describe('connectionSelectorLogic', () => {
])
logic = connectionSelectorLogic()
logic.mount()
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.MANAGED_TRINO_QUERY], {
+ [FEATURE_FLAGS.MANAGED_TRINO_QUERY]: true,
+ })
logic.actions.maybeLoadConnectionOptions()
await expectLogic(logic).toFinishAllListeners()
@@ -160,6 +176,7 @@ describe('connectionSelectorLogic', () => {
managementUrl: urls.dataWarehouseSource('managed-conn-duck'),
})
)
+ expect(externalOption.hidden).toBe(false)
})
it('derives the selected connection value from sql editor state', async () => {
diff --git a/products/data_warehouse/frontend/shared/logics/connectionSelectorLogic.ts b/products/data_warehouse/frontend/shared/logics/connectionSelectorLogic.ts
index 64b25d816edc..0913e809d53e 100644
--- a/products/data_warehouse/frontend/shared/logics/connectionSelectorLogic.ts
+++ b/products/data_warehouse/frontend/shared/logics/connectionSelectorLogic.ts
@@ -3,6 +3,8 @@ import { loaders } from 'kea-loaders'
import { ApiConfig } from 'lib/api'
import type { PaginatedResponse } from 'lib/api'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { type FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { urls } from 'scenes/urls'
import type { ExternalDataSource } from '~/types'
@@ -169,6 +171,7 @@ export function addHiddenSelectedConnectionOption(
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface connectionSelectorLogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
connectionOptions: ExternalDataSourceConnectionOptionApi[] | null
connectionOptionsLoading: boolean
connectionSelectOptions: ConnectionSelectOptionGroup[]
@@ -247,7 +250,8 @@ export interface connectionSelectorLogicMeta {
connectionOptions: ExternalDataSourceConnectionOptionApi[] | null,
connectionOptionsLoading: boolean,
directConnectionOptions: DirectConnectionSourceOptionApi[] | null,
- directConnectionOptionsLoading: boolean
+ directConnectionOptionsLoading: boolean,
+ featureFlags: FeatureFlagsSet
) => ConnectionSelectOptionGroup[]
}
}
@@ -263,6 +267,7 @@ export const connectionSelectorLogic = kea<connectionSelectorLogicType>([
path(['scenes', 'data-warehouse', 'editor', 'connectionSelectorLogic']),
connect(() => ({
actions: [sourcesDataLogic, ['loadSourcesSuccess']],
+ values: [featureFlagLogic, ['featureFlags']],
})),
actions({
maybeLoadConnectionOptions: true,
@@ -308,12 +313,14 @@ export const connectionSelectorLogic = kea<connectionSelectorLogicType>([
s.connectionOptionsLoading,
s.directConnectionOptions,
s.directConnectionOptionsLoading,
+ s.featureFlags,
],
(
connectionOptions: ExternalDataSourceConnectionOptionApi[] | null,
connectionOptionsLoading: boolean,
directConnectionOptions: DirectConnectionSourceOptionApi[] | null,
- directConnectionOptionsLoading: boolean
+ directConnectionOptionsLoading: boolean,
+ featureFlags: FeatureFlagsSet
): ConnectionSelectOptionGroup[] => {
const sourceOptions = connectionOptionsLoading
? [{ value: LOADING_CONNECTIONS, label: 'Loading...', disabled: true }]
@@ -323,6 +330,7 @@ export const connectionSelectorLogic = kea<connectionSelectorLogicType>([
value: source.id,
label: getConnectionOptionLabel(source),
iconSrc: isManagedWarehouse ? IconPostHog : ENGINE_ICONS[getConnectionEngine(source)],
+ hidden: isManagedWarehouse && !!featureFlags[FEATURE_FLAGS.MANAGED_TRINO_QUERY],
...(isManagedWarehouse
? {}
: { managementUrl: urls.dataWarehouseSource(`managed-${source.id}`) }),