Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): polish Warehouse connection methods (#50246)

Danny White4dd8a95f0b07
diff --git a/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx b/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx
index 33eaf0e619f..40af6cd9331 100644
--- a/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx
+++ b/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx
@@ -179,9 +179,7 @@ export const ConnectSheet = () => {
</div>
{state.mode === 'warehouse' ? (
- <div className="p-8">
- <WarehouseModePanel />
- </div>
+ <WarehouseModePanel />
) : (
<>
{activeFields.length > 0 && (
diff --git a/apps/studio/components/interfaces/ConnectSheet/CopyPromptAdmonition.tsx b/apps/studio/components/interfaces/ConnectSheet/CopyPromptAdmonition.tsx
index e29ea2f0c23..3563c82da8a 100644
--- a/apps/studio/components/interfaces/ConnectSheet/CopyPromptAdmonition.tsx
+++ b/apps/studio/components/interfaces/ConnectSheet/CopyPromptAdmonition.tsx
@@ -21,7 +21,9 @@ const normalizeTextLines = (value: string) => {
const getStepTextContent = (contentElement: HTMLElement) => {
const clone = contentElement.cloneNode(true) as HTMLElement
clone
- .querySelectorAll('pre, button, svg, input, textarea, select, [aria-hidden="true"]')
+ .querySelectorAll(
+ 'pre, button, svg, input, textarea, select, [aria-hidden="true"], [data-connect-prompt-ignore]'
+ )
.forEach((element) => {
element.remove()
})
@@ -45,6 +47,7 @@ const getStepCodeSnippets = (contentElement: HTMLElement) => {
}
const getSnippet = (element: Element) => {
+ if (element.closest('[data-connect-prompt-ignore]')) return undefined
const copyValueElement = element.closest('[data-connect-copy-value]') as HTMLElement | null
return copyValueElement?.dataset.connectCopyValue?.trim() || element.textContent?.trim()
}
@@ -62,7 +65,7 @@ const getStepCodeSnippets = (contentElement: HTMLElement) => {
if (tabSnippets.length === 0) {
const inlineSnippets = Array.from(tabContent.querySelectorAll('code'))
.filter((code) => !code.closest('pre') && code.closest('.font-mono'))
- .map((code) => code.textContent?.trim())
+ .map(getSnippet)
.filter((snippet): snippet is string => Boolean(snippet))
inlineSnippets.forEach((snippet, index) => {
const inlineLabel = inlineSnippets.length > 1 ? `${label} (part ${index + 1})` : label
@@ -87,7 +90,7 @@ const getStepCodeSnippets = (contentElement: HTMLElement) => {
if (code.closest('pre')) return
if (code.closest('[data-connect-tab-content]')) return
if (!code.closest('.font-mono')) return
- const snippet = code.textContent?.trim()
+ const snippet = getSnippet(code)
if (snippet) addSnippet('Code', snippet)
})
@@ -135,21 +138,25 @@ export function CopyPromptButton({ stepsContainerRef, customPrompt }: CopyPrompt
}, [showCopied])
return (
- <ButtonTooltip
- icon={showCopied ? <Check strokeWidth={2} className="text-brand" /> : <Copy />}
- onClick={() => {
- const textToCopy = customPrompt ?? buildConnectPrompt(stepsContainerRef.current)
- setShowCopied(true)
- copyToClipboard(textToCopy)
- }}
- tooltip={{
- content: {
- side: 'left',
- text: 'Copy these steps for your coding agent',
- },
- }}
- >
- {showCopied ? 'Copied' : 'Copy prompt'}
- </ButtonTooltip>
+ <>
+ <ButtonTooltip
+ icon={showCopied ? <Check strokeWidth={2} className="text-brand" /> : <Copy />}
+ onClick={() => {
+ const textToCopy = customPrompt ?? buildConnectPrompt(stepsContainerRef.current)
+ copyToClipboard(textToCopy, () => setShowCopied(true))
+ }}
+ tooltip={{
+ content: {
+ side: 'left',
+ text: 'Copy these steps for your coding agent',
+ },
+ }}
+ >
+ {showCopied ? 'Copied' : 'Copy prompt'}
+ </ButtonTooltip>
+ <span className="sr-only" role="status" aria-live="polite">
+ {showCopied ? 'Copied' : ''}
+ </span>
+ </>
)
}
diff --git a/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseConnectionDetails.test.tsx b/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseConnectionDetails.test.tsx
new file mode 100644
index 00000000000..7644198a14f
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseConnectionDetails.test.tsx
@@ -0,0 +1,152 @@
+import { screen, waitFor } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { platformComponents as components } from 'api-types'
+import { mockAnimationsApi } from 'jsdom-testing-mocks'
+import { HttpResponse } from 'msw'
+import { describe, expect, test, vi } from 'vitest'
+
+import { WarehouseConnectionDetails } from './WarehouseConnectionDetails'
+import { customRender } from '@/tests/lib/custom-render'
+import { addAPIMock } from '@/tests/lib/msw'
+
+type WarehouseCatalogResponse = components['schemas']['WarehouseCatalogResponse']
+type UpdateWarehouseCatalogBody = components['schemas']['UpdateWarehouseCatalogBody']
+
+const CATALOG_PASSWORD = 'pwd'
+const CATALOG_URL = 'postgres://postgres:[email protected]:5432/postgres'
+
+const mockCatalog = (catalog: WarehouseCatalogResponse) =>
+ addAPIMock({
+ method: 'get',
+ path: '/platform/warehouse/:ref/catalog',
+ response: () => HttpResponse.json<WarehouseCatalogResponse>(catalog),
+ })
+
+mockAnimationsApi()
+
+describe('WarehouseConnectionDetails', () => {
+ test('shows FlightSQL by default without loading DuckDB catalog access', async () => {
+ customRender(<WarehouseConnectionDetails onEditTables={vi.fn()} />)
+
+ expect(await screen.findByRole('combobox', { name: 'Query engine' })).toBeInTheDocument()
+ expect(screen.getByDisplayValue('default.warehouse.supabase.io')).toBeInTheDocument()
+ expect(
+ screen.getByDisplayValue(
+ 'flightsql://postgres:[YOUR-PASSWORD]@default.warehouse.supabase.io:443?tls=enabled'
+ )
+ ).toBeInTheDocument()
+ expect(screen.queryByRole('switch')).not.toBeInTheDocument()
+ })
+
+ test('shows the persistent catalog switch when DuckDB is selected', async () => {
+ mockCatalog({ enabled: false })
+
+ customRender(<WarehouseConnectionDetails onEditTables={vi.fn()} />)
+
+ await userEvent.click(await screen.findByRole('combobox', { name: 'Query engine' }))
+ await userEvent.click(screen.getByRole('option', { name: 'DuckDB' }))
+
+ expect(
+ await screen.findByRole('switch', { name: 'Enable DuckDB catalog access' })
+ ).not.toBeChecked()
+ expect(screen.queryByRole('heading', { name: 'Follow these steps' })).not.toBeInTheDocument()
+ })
+
+ test('shows DuckDB credentials as numbered steps and removes them when changing engines', async () => {
+ mockCatalog({
+ enabled: true,
+ credentials: {
+ catalog_url: CATALOG_URL,
+ data_path: 's3://warehouse/',
+ metadata_schema: 'ducklake',
+ s3_access_key_id: 'access-key-id',
+ s3_endpoint: 'default.storage.supabase.co/storage/v1/s3',
+ s3_region: 'ap-southeast-1',
+ s3_secret_access_key: 's3-secret',
+ },
+ })
+
+ customRender(<WarehouseConnectionDetails onEditTables={vi.fn()} />)
+
+ await userEvent.click(await screen.findByRole('combobox', { name: 'Query engine' }))
+ await userEvent.click(screen.getByRole('option', { name: 'DuckDB' }))
+
+ expect(
+ await screen.findByRole('switch', { name: 'Enable DuckDB catalog access' })
+ ).toBeChecked()
+ expect(screen.getByRole('heading', { name: 'Follow these steps' })).toBeInTheDocument()
+ expect(screen.getByText('Set environment variables')).toBeInTheDocument()
+ expect(screen.getByText('Attach Warehouse')).toBeInTheDocument()
+ expect(
+ screen.getByRole('button', { name: 'Copy all DuckLake environment variables' })
+ ).toBeInTheDocument()
+
+ expect(screen.queryByText('s3-secret')).not.toBeInTheDocument()
+ await userEvent.click(screen.getByRole('button', { name: 'Reveal DUCKLAKE_S3_SECRET' }))
+ expect(screen.getByText('s3-secret')).toBeInTheDocument()
+
+ expect(screen.queryByText(CATALOG_PASSWORD)).not.toBeInTheDocument()
+ await userEvent.click(screen.getByRole('button', { name: 'Reveal DUCKLAKE_METADATA_PASSWORD' }))
+ expect(screen.getByText(CATALOG_PASSWORD)).toBeInTheDocument()
+
+ await userEvent.click(screen.getByRole('combobox', { name: 'Query engine' }))
+ await userEvent.click(screen.getByRole('option', { name: 'FlightSQL' }))
+
+ expect(screen.queryByRole('heading', { name: 'Follow these steps' })).not.toBeInTheDocument()
+ expect(screen.queryByRole('button', { name: 'Copy prompt' })).not.toBeInTheDocument()
+ })
+
+ test('enables and disables DuckDB catalog access', async () => {
+ let catalog: WarehouseCatalogResponse = { enabled: false }
+ const requestBodies: UpdateWarehouseCatalogBody[] = []
+ let finishUpdatingCatalog: (() => void) | undefined
+ const updatingCatalog = new Promise<void>((resolve) => {
+ finishUpdatingCatalog = resolve
+ })
+
+ addAPIMock({
+ method: 'get',
+ path: '/platform/warehouse/:ref/catalog',
+ response: () => HttpResponse.json<WarehouseCatalogResponse>(catalog),
+ })
+ addAPIMock({
+ method: 'post',
+ path: '/platform/warehouse/:ref/catalog',
+ response: async ({ request }) => {
+ const body = (await request.json()) as UpdateWarehouseCatalogBody
+ requestBodies.push(body)
+ await updatingCatalog
+ catalog = { enabled: body.enabled }
+ return HttpResponse.json<WarehouseCatalogResponse>(catalog)
+ },
+ })
+
+ customRender(<WarehouseConnectionDetails onEditTables={vi.fn()} />)
+
+ await userEvent.click(await screen.findByRole('combobox', { name: 'Query engine' }))
+ await userEvent.click(screen.getByRole('option', { name: 'DuckDB' }))
+
+ const catalogSwitch = await screen.findByRole('switch', {
+ name: 'Enable DuckDB catalog access',
+ })
+ expect(catalogSwitch).not.toBeChecked()
+
+ await userEvent.click(catalogSwitch)
+ expect(
+ await screen.findByRole('status', { name: 'Updating DuckDB catalog access' })
+ ).toBeInTheDocument()
+ expect(catalogSwitch).toBeDisabled()
+ expect(catalogSwitch).toHaveAttribute('aria-busy', 'true')
+
+ finishUpdatingCatalog?.()
+ await waitFor(() => expect(catalogSwitch).toBeChecked())
+ expect(
+ screen.queryByRole('status', { name: 'Updating DuckDB catalog access' })
+ ).not.toBeInTheDocument()
+
+ await userEvent.click(catalogSwitch)
+ await waitFor(() => expect(catalogSwitch).not.toBeChecked())
+
+ expect(requestBodies).toEqual([{ enabled: true }, { enabled: false }])
+ })
+})
diff --git a/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseConnectionDetails.tsx b/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseConnectionDetails.tsx
index 3c5e756ff88..4e3b318545c 100644
--- a/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseConnectionDetails.tsx
+++ b/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseConnectionDetails.tsx
@@ -1,14 +1,33 @@
import { useParams } from 'common'
-import { KeyRound } from 'lucide-react'
+import { Eye, EyeOff, KeyRound, Loader2 } from 'lucide-react'
import Link from 'next/link'
-import { Badge, Button } from 'ui'
+import { useRef, useState } from 'react'
+import { toast } from 'sonner'
+import {
+ Badge,
+ Button,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ Switch,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { CodeBlock } from 'ui-patterns/CodeBlock'
import { Input } from 'ui-patterns/DataInputs/Input'
+import { FormLayout } from 'ui-patterns/form/Layout/FormLayout'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
+import { ConnectSheetStep } from '../ConnectSheetStep'
+import { EnvRow } from '../content/server/common/EnvRow'
+import { CopyPromptButton } from '../CopyPromptAdmonition'
import type { WarehouseCatalogCredentials } from './WarehouseModePanel.utils'
import { AlertError } from '@/components/ui/AlertError'
+import CopyButton from '@/components/ui/CopyButton'
import { useUpdateWarehouseCatalogMutation } from '@/data/warehouse/warehouse-catalog-mutation'
import { useWarehouseCatalogQuery } from '@/data/warehouse/warehouse-catalog-query'
import {
@@ -21,182 +40,291 @@ import {
parseWarehouseCatalogUrl,
} from '@/lib/warehouse'
+const QUERY_ENGINES = [
+ { value: 'flightsql', label: 'FlightSQL' },
+ { value: 'duckdb', label: 'DuckDB' },
+] as const
+
+type QueryEngine = (typeof QUERY_ENGINES)[number]['value']
+
export interface WarehouseConnectionDetailsProps {
onEditTables: () => void
}
-function FieldRow({ label, children }: { label: React.ReactNode; children: React.ReactNode }) {
+function FieldRow({
+ id,
+ label,
+ children,
+}: {
+ id?: string
+ label: React.ReactNode
+ children: React.ReactNode
+}) {
+ return (
+ <FormLayout id={id} layout="horizontal" label={label}>
+ {children}
+ </FormLayout>
+ )
+}
+
+const FlightSqlContent = ({ projectRef }: { projectRef: string }) => (
+ <div className="space-y-4">
+ <FieldRow id="warehouse-flightsql-endpoint" label="Endpoint">
+ <Input
+ id="warehouse-flightsql-endpoint"
+ readOnly
+ copy
+ className="font-mono"
+ value={getWarehouseFlightSqlEndpoint(projectRef)}
+ />
+ </FieldRow>
+ <FieldRow id="warehouse-flightsql-connection-string" label="Connection string">
+ <Input
+ id="warehouse-flightsql-connection-string"
+ readOnly
+ copy
+ className="font-mono"
+ value={getWarehouseFlightSqlConnectionString(projectRef)}
+ />
+ </FieldRow>
+ <FieldRow id="warehouse-flightsql-user" label="User">
+ <Input id="warehouse-flightsql-user" readOnly copy className="font-mono" value="postgres" />
+ </FieldRow>
+ <FieldRow label="Password">
+ <div className="flex justify-end">
+ <Button asChild variant="default" size="tiny" icon={<KeyRound size={14} />}>
+ <Link href={`/project/${projectRef}/settings/database`}>Reset database password</Link>
+ </Button>
+ </div>
+ </FieldRow>
+ <FieldRow label="Command line">
+ <CodeBlock
+ className="[&_code]:text-foreground"
+ language="bash"
+ hideLineNumbers
+ wrapLongLines
+ value={getWarehouseUsqlCommand(projectRef)}
+ />
+ </FieldRow>
+ </div>
+)
+
+const DuckLakeSecretRow = ({ name, value }: { name: string; value: string }) => {
+ const [isRevealed, setIsRevealed] = useState(false)
+
+ return (
+ <EnvRow name={name} value={isRevealed ? value : '•'.repeat(16)}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="default"
+ size="tiny"
+ className="px-1.5"
+ aria-label={`${isRevealed ? 'Hide' : 'Reveal'} ${name}`}
+ icon={isRevealed ? <EyeOff strokeWidth={2} /> : <Eye strokeWidth={2} />}
+ onClick={() => setIsRevealed((value) => !value)}
+ />
+ </TooltipTrigger>
+ <TooltipContent side="bottom">
+ {isRevealed ? 'Hide environment variable' : 'Reveal environment variable'}
+ </TooltipContent>
+ </Tooltip>
+ <CopyButton variant="default" size="tiny" iconOnly aria-label={`Copy ${name}`} text={value} />
+ </EnvRow>
+ )
+}
+
+const DuckLakeEnvironmentVariables = ({
+ credentials,
+ password,
+}: {
+ credentials: WarehouseCatalogCredentials
+ password: string
+}) => {
+ const environmentVariables = [
+ `${DUCKLAKE_S3_SECRET_ENV_VAR}=${credentials.s3_secret_access_key}`,
+ `${DUCKLAKE_METADATA_PASSWORD_ENV_VAR}=${password}`,
+ ].join('\n')
+
return (
- // `minmax(0,1fr)` rather than `1fr`: a 1fr track keeps `min-width: auto`, so a long
- // single-line value (the FlightSQL connection string) stretches the track past the panel
- // instead of truncating inside it.
- <div className="grid grid-cols-[180px_minmax(0,1fr)] gap-4 items-center">
- <span className="text-sm text-foreground-light">{label}</span>
- <div className="min-w-0">{children}</div>
+ <div className="overflow-hidden rounded-lg border bg-surface-75" data-connect-prompt-ignore>
+ <div className="flex items-center justify-between border-b bg-surface-100 py-2 pl-4 pr-2">
+ <span className="font-mono text-xs text-foreground-light">.env</span>
+ <CopyButton
+ variant="default"
+ size="tiny"
+ copyLabel="Copy all"
+ aria-label="Copy all DuckLake environment variables"
+ text={environmentVariables}
+ />
+ </div>
+ <div className="divide-y">
+ <DuckLakeSecretRow
+ name={DUCKLAKE_S3_SECRET_ENV_VAR}
+ value={credentials.s3_secret_access_key}
+ />
+ <DuckLakeSecretRow name={DUCKLAKE_METADATA_PASSWORD_ENV_VAR} value={password} />
+ </div>
</div>
)
}
-/**
- * The DuckDB setup script inlines everything except the two passwords, which it reads via
- * `getenv()` — so those are the only credential values surfaced as their own rows here.
- */
-function DuckLakeSetup({ credentials }: { credentials: WarehouseCatalogCredentials }) {
+const DuckLakeSetup = ({ credentials }: { credentials: WarehouseCatalogCredentials }) => {
const connection = parseWarehouseCatalogUrl(credentials.catalog_url)
+ const stepsContainerRef = useRef<HTMLDivElement | null>(null)
if (connection === null) {
return (
- <div className="flex flex-col gap-3 mt-2">
+ <div className="space-y-4 border-t bg-muted/50 p-8">
<Admonition
type="warning"
title="Could not read the catalog connection details"
description="Copy the catalog URL and configure the DuckLake secrets manually."
/>
- <FieldRow label="Catalog URL">
- <Input readOnly copy reveal className="font-mono" value={credentials.catalog_url} />
+ <FieldRow id="warehouse-catalog-url" label="Catalog URL">
+ <Input
+ id="warehouse-catalog-url"
+ readOnly
+ copy
+ reveal
+ className="font-mono"
+ value={credentials.catalog_url}
+ />
</FieldRow>
</div>
)
}
- const setupScript = getDuckLakeSetupScript({ credentials, connection })
+ return (
+ <div className="border-t bg-muted/50 p-8">
+ <div className="mb-6 flex items-center justify-between gap-4">
+ <h3>Follow these steps</h3>
+ <CopyPromptButton stepsContainerRef={stepsContainerRef} />
+ </div>
+ <div ref={stepsContainerRef}>
+ <ConnectSheetStep
+ number={1}
+ title="Set environment variables"
+ description="Add these credentials to your environment before running the SQL."
+ >
+ <DuckLakeEnvironmentVariables credentials={credentials} password={connection.password} />
+ </ConnectSheetStep>
+ <ConnectSheetStep
+ number={2}
+ title="Attach Warehouse"
+ description="Run this script in DuckDB to configure the secrets and attach Warehouse."
+ >
+ <CodeBlock
+ className="[&_code]:text-foreground"
+ language="sql"
+ hideLineNumbers
+ value={getDuckLakeSetupScript({ credentials, connection })}
+ />
+ </ConnectSheetStep>
+ </div>
+ </div>
+ )
+}
+
+const CatalogAccessToggle = ({
+ projectRef,
+ isEnabled,
+}: {
+ projectRef: string
+ isEnabled: boolean
+}) => {
+ const catalogMutation = useUpdateWarehouseCatalogMutation({
+ onSuccess: (catalog) =>
+ toast.success(
+ catalog?.enabled ? 'DuckDB catalog access enabled' : 'DuckDB catalog access disabled'
+ ),
+ })
return (
- <div className="flex flex-col gap-3 mt-2">
- <p className="text-sm text-foreground-light max-w-xl mb-1">
- Attach this project's Warehouse directly from DuckDB. The script reads both passwords from
- environment variables — set these before running it:
- </p>
- <FieldRow label={<span className="font-mono text-xs">{DUCKLAKE_S3_SECRET_ENV_VAR}</span>}>
- <Input
- readOnly
- copy
- reveal
- className="font-mono"
- value={credentials.s3_secret_access_key}
+ <FormLayout
+ layout="flex-row-reverse"
+ label="Enable DuckDB catalog access"
+ description="Creates the credentials DuckDB needs to attach Warehouse. Not required for FlightSQL."
+ >
+ <div className="flex items-center justify-end gap-2">
+ {catalogMutation.isPending && (
+ <span role="status" aria-label="Updating DuckDB catalog access">
+ <Loader2 size={16} className="animate-spin text-foreground-muted" aria-hidden />
+ </span>
+ )}
+ <Switch
+ aria-label="Enable DuckDB catalog access"
+ aria-busy={catalogMutation.isPending}
+ checked={isEnabled}
+ disabled={catalogMutation.isPending}
+ onCheckedChange={(enabled) => catalogMutation.mutate({ projectRef, body: { enabled } })}
/>
- </FieldRow>
- <FieldRow
- label={<span className="font-mono text-xs">{DUCKLAKE_METADATA_PASSWORD_ENV_VAR}</span>}
- >
- <Input readOnly copy reveal className="font-mono" value={connection.password} />
- </FieldRow>
- {/*
- `className` is what switches CodeBlock from its plain <code> fallback to the syntax
- highlighter — without it the SQL renders unhighlighted and the blank lines between steps
- collapse.
- */}
- <CodeBlock
- className="[&_code]:text-foreground"
- language="sql"
- hideLineNumbers
- value={setupScript}
- />
- </div>
+ </div>
+ </FormLayout>
)
}
export const WarehouseConnectionDetails = ({ onEditTables }: WarehouseConnectionDetailsProps) => {
const { ref: projectRef } = useParams()
+ const [engine, setEngine] = useState<QueryEngine>('flightsql')
const {
data: catalog,
isPending: isCatalogPending,
isError: isCatalogError,
error: catalogError,
- } = useWarehouseCatalogQuery({ projectRef })
- const catalogMutation = useUpdateWarehouseCatalogMutation()
+ } = useWarehouseCatalogQuery({ projectRef }, { enabled: engine === 'duckdb' })
if (!projectRef) return null
- const endpoint = getWarehouseFlightSqlEndpoint(projectRef)
- const connectionString = getWarehouseFlightSqlConnectionString(projectRef)
- const usqlCommand = getWarehouseUsqlCommand(projectRef)
+ let catalogStatus = ''
+ if (engine === 'duckdb' && isCatalogPending) catalogStatus = 'Loading DuckDB catalog access'
+ if (engine === 'duckdb' && !isCatalogPending && !isCatalogError) {
+ catalogStatus = 'DuckDB catalog access loaded'
+ }
return (
<div>
- <div className="flex items-center gap-3 mb-5">
- <Badge variant="success">Warehouse enabled</Badge>
- <button
- type="button"
- tabIndex={0}
- onClick={onEditTables}
- className="text-sm text-foreground-light underline underline-offset-2 ml-auto"
- >
- Edit replicated tables
- </button>
- </div>
+ <div className="space-y-4 p-8">
+ <div className="flex items-center gap-3">
+ <Badge variant="success">Warehouse enabled</Badge>
+ <Button className="ml-auto" variant="text" size="tiny" onClick={onEditTables}>
+ Edit replicated tables
+ </Button>
+ </div>
- <h3 className="text-sm font-medium text-foreground mb-3">External access</h3>
- <div className="flex flex-col gap-3">
- <FieldRow label="Endpoint">
- <Input readOnly copy className="font-mono" value={endpoint} />
+ <FieldRow id="warehouse-query-engine" label="Query engine">
+ <Select value={engine} onValueChange={(value) => setEngine(value as QueryEngine)}>
+ <SelectTrigger id="warehouse-query-engine" className="ml-auto w-48">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent align="end">
+ {QUERY_ENGINES.map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
</FieldRow>
- <FieldRow label="Connection string">
- <Input readOnly copy className="font-mono" value={connectionString} />
- </FieldRow>
- <FieldRow label="User">
- <Input readOnly copy className="font-mono" value="postgres" />
- </FieldRow>
- <FieldRow label="Password">
- <div className="flex items-center gap-3">
- <span className="text-sm text-foreground-light">
- Same password as your primary database.
- </span>
- <Button asChild size="tiny" icon={<KeyRound size={14} />} className="ml-auto">
- <Link href={`/project/${projectRef}/settings/database`}>Reset database password</Link>
- </Button>
- </div>
- </FieldRow>
- </div>
- <div className="h-px bg-border my-6" />
+ {engine === 'flightsql' && <FlightSqlContent projectRef={projectRef} />}
- <h3 className="text-sm font-medium text-foreground mb-1">Connect with FlightSQL</h3>
- <p className="text-sm text-foreground-light max-w-xl mb-3">
- Warehouse speaks the Arrow FlightSQL protocol. Any FlightSQL-compatible client can connect —
- for example, using the <span className="font-mono">usql</span> CLI:
- </p>
- <CodeBlock
- className="[&_code]:text-foreground"
- language="bash"
- hideLineNumbers
- wrapLongLines
- value={usqlCommand}
- />
-
- <div className="h-px bg-border my-6" />
-
- <h3 className="text-sm font-medium text-foreground mb-1">
- Connect with DuckDB (DuckLake catalog)
- </h3>
-
- {isCatalogPending && <GenericSkeletonLoader />}
-
- {isCatalogError && (
- <AlertError
- className="mt-2"
- subject="Failed to load DuckLake catalog access"
- error={catalogError}
- />
- )}
-
- {!isCatalogPending && !isCatalogError && !catalog?.enabled && (
- <div className="flex items-center gap-3 mt-2">
- <p className="text-sm text-foreground-light max-w-lg">
- Enable catalog access to attach this project's Warehouse directly from DuckDB.
- </p>
- <Button
- className="ml-auto shrink-0"
- loading={catalogMutation.isPending}
- onClick={() => catalogMutation.mutate({ projectRef, body: { enabled: true } })}
- >
- Enable catalog access
- </Button>
- </div>
- )}
+ {engine === 'duckdb' && (
+ <>
+ {isCatalogPending && <GenericSkeletonLoader />}
+ {isCatalogError && (
+ <AlertError subject="Failed to load DuckLake catalog access" error={catalogError} />
+ )}
+ {catalog && <CatalogAccessToggle projectRef={projectRef} isEnabled={catalog.enabled} />}
+ </>
+ )}
+ <span className="sr-only" role="status" aria-live="polite">
+ {catalogStatus}
+ </span>
+ </div>
- {!isCatalogPending && !isCatalogError && catalog?.enabled && catalog.credentials && (
+ {engine === 'duckdb' && catalog?.enabled && catalog.credentials && (
<DuckLakeSetup credentials={catalog.credentials} />
)}
</div>
diff --git a/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseModePanel.tsx b/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseModePanel.tsx
index b1ae5ddc98d..fac16abd83e 100644
--- a/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseModePanel.tsx
+++ b/apps/studio/components/interfaces/ConnectSheet/WarehouseModePanel/WarehouseModePanel.tsx
@@ -1,6 +1,5 @@
import { useParams } from 'common'
import { useState } from 'react'
-import { toast } from 'sonner'
import { Button } from 'ui'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
@@ -9,7 +8,6 @@ import { WarehouseEnablingProgress } from './WarehouseEnablingProgress'
import type { WarehouseSetupTarget } from './WarehouseModePanel.utils'
import { WarehouseSchemaTablePicker } from './WarehouseSchemaTablePicker'
import { AlertError } from '@/components/ui/AlertError'
-import { useUpdateWarehouseCatalogMutation } from '@/data/warehouse/warehouse-catalog-mutation'
import { useWarehouseSetupMutation } from '@/data/warehouse/warehouse-setup-mutation'
import { useWarehouseSetupStatusQuery } from '@/data/warehouse/warehouse-setup-status-query'
@@ -25,11 +23,13 @@ const WarehouseSetupComplete = ({ onSubmit, isSubmitting }: WarehouseSetupComple
if (isEditingTables) {
return (
- <WarehouseSchemaTablePicker
- onSubmit={onSubmit}
- isSubmitting={isSubmitting}
- onBack={() => setIsEditingTables(false)}
- />
+ <div className="p-8">
+ <WarehouseSchemaTablePicker
+ onSubmit={onSubmit}
+ isSubmitting={isSubmitting}
+ onBack={() => setIsEditingTables(false)}
+ />
+ </div>
)
}
@@ -49,44 +49,52 @@ export const WarehouseModePanel = () => {
}
)
- const catalogMutation = useUpdateWarehouseCatalogMutation({
- onError: (error) => {
- toast.error(
- `Warehouse was enabled, but DuckLake catalog access could not be enabled automatically: ${error.message}. You can retry this from the connection details.`
- )
- },
- })
const setupMutation = useWarehouseSetupMutation()
const handleSetup = (targets: WarehouseSetupTarget[]) => {
if (!projectRef || targets.length === 0) return
- setupMutation.mutate(
- { projectRef, body: { targets } },
- {
- onSuccess: () => {
- // Fire-and-forget: setup itself should proceed even if enabling catalog access fails.
- // The connection details panel offers a manual "Enable catalog access" fallback.
- catalogMutation.mutate({ projectRef, body: { enabled: true } })
- },
- }
- )
+ setupMutation.mutate({ projectRef, body: { targets } })
}
- if (isPending) return <GenericSkeletonLoader />
- if (isError) return <AlertError subject="Failed to load Warehouse status" error={error} />
- if (!data) return <GenericSkeletonLoader />
+ if (isPending) {
+ return (
+ <div className="p-8">
+ <GenericSkeletonLoader />
+ </div>
+ )
+ }
+ if (isError) {
+ return (
+ <div className="p-8">
+ <AlertError subject="Failed to load Warehouse status" error={error} />
+ </div>
+ )
+ }
+ if (!data) {
+ return (
+ <div className="p-8">
+ <GenericSkeletonLoader />
+ </div>
+ )
+ }
const status = data.setup_status
if (status === 'not_started') {
return (
- <WarehouseSchemaTablePicker onSubmit={handleSetup} isSubmitting={setupMutation.isPending} />
+ <div className="p-8">
+ <WarehouseSchemaTablePicker onSubmit={handleSetup} isSubmitting={setupMutation.isPending} />
+ </div>
)
}
if (status === 'setting_up' || status === 'copying') {
- return <WarehouseEnablingProgress status={data} />
+ return (
+ <div className="p-8">
+ <WarehouseEnablingProgress status={data} />
+ </div>
+ )
}
if (status === 'error') {
@@ -98,19 +106,22 @@ export const WarehouseModePanel = () => {
const failingStep = data.steps.find((step) => step.status === 'error')
return (
- <AlertError
- subject="Warehouse setup failed"
- error={{
- message: failingStep?.message ?? 'An unknown error occurred while setting up Warehouse.',
- }}
- additionalActions={
- retryTargets.length > 0 ? (
- <Button loading={setupMutation.isPending} onClick={() => handleSetup(retryTargets)}>
- Retry
- </Button>
- ) : undefined
- }
- />
+ <div className="p-8">
+ <AlertError
+ subject="Warehouse setup failed"
+ error={{
+ message:
+ failingStep?.message ?? 'An unknown error occurred while setting up Warehouse.',
+ }}
+ additionalActions={
+ retryTargets.length > 0 ? (
+ <Button loading={setupMutation.isPending} onClick={() => handleSetup(retryTargets)}>
+ Retry
+ </Button>
+ ) : undefined
+ }
+ />
+ </div>
)
}
diff --git a/apps/studio/components/interfaces/ConnectSheet/__tests__/CopyPromptAdmonition.test.ts b/apps/studio/components/interfaces/ConnectSheet/__tests__/CopyPromptAdmonition.test.ts
index f62ff2d7ce2..22769daa6d4 100644
--- a/apps/studio/components/interfaces/ConnectSheet/__tests__/CopyPromptAdmonition.test.ts
+++ b/apps/studio/components/interfaces/ConnectSheet/__tests__/CopyPromptAdmonition.test.ts
@@ -28,4 +28,54 @@ describe('buildConnectPrompt', () => {
)
expect(prompt).not.toContain('temporary-password')
})
+
+ test('omits content marked as sensitive', () => {
+ const container = document.createElement('div')
+ container.innerHTML = `
+ <div
+ data-connect-step
+ data-step-title="Set environment variables"
+ data-step-description="Add these credentials to your environment."
+ >
+ <div data-step-content>
+ <div data-connect-prompt-ignore>
+ DUCKLAKE_S3_SECRET=temporary-secret
+ </div>
+ </div>
+ </div>
+ `
+
+ const prompt = buildConnectPrompt(container)
+
+ expect(prompt).toContain('Set environment variables')
+ expect(prompt).not.toContain('temporary-secret')
+ })
+
+ test('omits inline code marked as sensitive', () => {
+ const container = document.createElement('div')
+ container.innerHTML = `
+ <div
+ data-connect-step
+ data-step-title="Set environment variables"
+ data-step-description="Add these credentials to your environment."
+ >
+ <div data-step-content>
+ <div class="font-mono" data-connect-prompt-ignore>
+ <code>DUCKLAKE_S3_SECRET=temporary-secret</code>
+ </div>
+ <div data-connect-tab-content data-tab-label="Shell">
+ <div class="font-mono" data-connect-prompt-ignore>
+ <code>DUCKLAKE_METADATA_PASSWORD=temporary-password</code>
+ </div>
+ </div>
+ </div>
+ </div>
+ `
+
+ const prompt = buildConnectPrompt(container)
+
+ expect(prompt).toContain('Set environment variables')
+ expect(prompt).not.toContain('temporary-secret')
+ expect(prompt).not.toContain('temporary-password')
+ })
})
diff --git a/apps/studio/lib/warehouse.ts b/apps/studio/lib/warehouse.ts
index b7557379540..1e95b41fa01 100644
--- a/apps/studio/lib/warehouse.ts
+++ b/apps/studio/lib/warehouse.ts
@@ -10,7 +10,7 @@ const WAREHOUSE_TLD = IS_STAGING_OR_LOCAL ? 'red' : 'io'
export const WAREHOUSE_PUBLICATION_NAME = 'supabase_warehouse'
/**
- * Postgres schema the managed Warehouse destination keeps its DuckLake catalog in —
+ * Postgres schema the managed Warehouse destination keeps its DuckLake catalog in.
* `WAREHOUSE_METADATA_SCHEMA` in the platform repo, where it's a hardcoded constant: the schema is
* always provisioned under this name, the destination config is always built with it, and no
* request body accepts an override. Mirrored here so the schema picker can exclude it; the platform
@@ -73,7 +73,7 @@ export function parseWarehouseCatalogUrl(catalogUrl: string): WarehouseCatalogCo
* Postgres secret for the metadata catalog, a DuckLake secret binding the two, then the attach.
*
* Both passwords are read via `getenv()` rather than inlined, so the script is safe to copy into a
- * shared file — the values themselves are surfaced separately in the UI.
+ * shared file. The values themselves are surfaced separately in the UI.
*
* `METADATA_SCHEMA` is set explicitly because DuckLake defaults it to `main`, not to the schema the
* platform provisions.
@@ -91,7 +91,7 @@ export function getDuckLakeSetupScript({
}
connection: WarehouseCatalogConnection
}): string {
- return `-- 1. S3 credentials for reading the Warehouse data files
+ return `-- S3 credentials for reading the Warehouse data files
CREATE OR REPLACE SECRET ducklake_s3 (
TYPE s3,
KEY_ID '${credentials.s3_access_key_id}',
@@ -101,7 +101,7 @@ CREATE OR REPLACE SECRET ducklake_s3 (
URL_STYLE 'path'
);
--- 2. Postgres credentials for the DuckLake metadata catalog
+-- Postgres credentials for the DuckLake metadata catalog
CREATE OR REPLACE SECRET ducklake_metadata (
TYPE postgres,
HOST '${connection.host}',
@@ -111,7 +111,7 @@ CREATE OR REPLACE SECRET ducklake_metadata (
PASSWORD getenv('${DUCKLAKE_METADATA_PASSWORD_ENV_VAR}')
);
--- 3. Bind the metadata secret into a DuckLake secret configuration
+-- Bind the metadata secret into a DuckLake secret configuration
CREATE OR REPLACE SECRET ducklake_warehouse (
TYPE ducklake,
METADATA_PATH '',
@@ -123,6 +123,6 @@ CREATE OR REPLACE SECRET ducklake_warehouse (
}
);
--- 4. Clean attach using only the secret identifier
+-- Attach Warehouse using only the secret identifier
ATTACH 'ducklake:ducklake_warehouse' AS warehouse;`
}