mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem Retire the deprecated Iceberg (Analytics Bucket) destination from Pipelines. ## Solution - Remove the destination UI, configuration mappings, feature-flag usage, and generated API variants. - Remove the legacy Pipelines integration from Storage while preserving standalone Analytics Buckets. - Remove unused components and sheet-layout support, and add regression coverage for retained Storage operations. - Remove the stale Pipelines claim from the Storage docs overview. ## Validation - Pipelines, Storage, and replication data tests - After the final cleanup: Studio typecheck and all 3 Analytics Bucket regression tests passed. - Formatting, scoped ESLint, Knip, and whitespace checks passed; lint warnings are pre-existing. - Storage overview: Prettier, ESLint with zero warnings, content-listing schema validation, and Markdown rendering passed. Production API-type verification remains pending the coordinated API deployment. Legacy Iceberg pipelines, destinations, and slots must be cleaned up before rollout. ## Review instructions 1. Verify that Pipelines offers BigQuery, DuckLake, Snowflake, and ClickHouse, with no Analytics Bucket option. 2. Verify that Storage Analytics Bucket creation, namespace/table operations, and wrapper/key cleanup remain available without Pipelines controls. ## Checklist - [x] Read CONTRIBUTING.md. - [x] Updated the Storage overview copy and checked the docs authoring guidance. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
232 lines
6.9 KiB
TypeScript
232 lines
6.9 KiB
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
import { components } from 'api-types'
|
|
import { toast } from 'sonner'
|
|
|
|
import { optionalSecret } from './destination-secret-utils'
|
|
import { invalidateReplicationPipelineQueries } from './invalidate-pipeline-queries'
|
|
import { replicationKeys } from './keys'
|
|
import type {
|
|
BigQueryDestinationConfig,
|
|
BigQueryTableOption,
|
|
DestinationConfig,
|
|
DucklakeDestinationConfig,
|
|
PipelineConfig,
|
|
} from './types'
|
|
import {
|
|
buildBigQueryTableOptionApiConfig,
|
|
buildPipelineApiConfig,
|
|
getConfiguredBigQueryTableOptions,
|
|
isDucklakeSupabaseConfig,
|
|
} from './utils'
|
|
import { handleError, post } from '@/data/fetchers'
|
|
import type { StudioError } from '@/lib/errors/studio-errors'
|
|
import type { UseCustomMutationOptions } from '@/types'
|
|
|
|
type UpdateDestinationPipelineBody =
|
|
components['schemas']['UpdateReplicationDestinationPipelineBody']
|
|
type UpdateDestinationApiConfig = UpdateDestinationPipelineBody['destination_config']
|
|
|
|
type UpdateBigQueryApiConfig = Extract<UpdateDestinationApiConfig, { big_query: unknown }>
|
|
type UpdateDucklakeApiConfig = Extract<UpdateDestinationApiConfig, { ducklake: unknown }>
|
|
|
|
const buildBigQueryTableOptionsUpdateApiConfig = (
|
|
tableOptions: BigQueryTableOption[] | undefined
|
|
) => {
|
|
const configuredTableOptions = getConfiguredBigQueryTableOptions(tableOptions)
|
|
if (tableOptions === undefined) return undefined
|
|
if (configuredTableOptions.length === 0) return null
|
|
return { tables: configuredTableOptions.map(buildBigQueryTableOptionApiConfig) }
|
|
}
|
|
|
|
export function buildBigQueryUpdateApiConfig(
|
|
config: BigQueryDestinationConfig
|
|
): UpdateBigQueryApiConfig {
|
|
return {
|
|
big_query: {
|
|
project_id: config.projectId,
|
|
dataset_id: config.datasetId,
|
|
service_account_key: optionalSecret(config.serviceAccountKey),
|
|
connection_pool_size: config.connectionPoolSize,
|
|
max_staleness_mins: config.maxStalenessMins,
|
|
table_options: buildBigQueryTableOptionsUpdateApiConfig(config.tableOptions),
|
|
},
|
|
}
|
|
}
|
|
|
|
export function buildDucklakeUpdateApiConfig(
|
|
config: DucklakeDestinationConfig
|
|
): UpdateDucklakeApiConfig {
|
|
if (isDucklakeSupabaseConfig(config)) {
|
|
return {
|
|
ducklake: {
|
|
catalog: {
|
|
type: 'supabase_project',
|
|
project_ref: config.catalogProjectRef,
|
|
pool_size: config.poolSize,
|
|
metadata_schema: config.metadataSchema,
|
|
},
|
|
storage: {
|
|
type: 'supabase_storage',
|
|
project_ref: config.storageProjectRef,
|
|
bucket: config.bucket,
|
|
...(config.path ? { path: config.path } : {}),
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
return {
|
|
ducklake: {
|
|
catalog_url: optionalSecret(config.catalogUrl),
|
|
data_path: config.dataPath,
|
|
pool_size: config.poolSize,
|
|
s3_access_key_id: optionalSecret(config.s3AccessKeyId),
|
|
s3_secret_access_key: optionalSecret(config.s3SecretAccessKey),
|
|
s3_region: config.s3Region,
|
|
s3_endpoint: config.s3Endpoint,
|
|
s3_url_style: config.s3UrlStyle,
|
|
s3_use_ssl: config.s3UseSsl,
|
|
metadata_schema: config.metadataSchema,
|
|
},
|
|
}
|
|
}
|
|
|
|
export const buildUpdateDestinationApiConfig = (
|
|
destinationConfig: DestinationConfig
|
|
): UpdateDestinationApiConfig => {
|
|
if ('bigQuery' in destinationConfig) {
|
|
return buildBigQueryUpdateApiConfig(destinationConfig.bigQuery)
|
|
}
|
|
|
|
if ('ducklake' in destinationConfig) {
|
|
return buildDucklakeUpdateApiConfig(destinationConfig.ducklake)
|
|
}
|
|
|
|
if ('snowflake' in destinationConfig) {
|
|
const { accountId, user, privateKey, privateKeyPassphrase, database, schema, role } =
|
|
destinationConfig.snowflake
|
|
|
|
return {
|
|
snowflake: {
|
|
account_id: accountId,
|
|
user,
|
|
private_key: optionalSecret(privateKey),
|
|
private_key_passphrase: optionalSecret(privateKeyPassphrase),
|
|
database,
|
|
schema,
|
|
role,
|
|
},
|
|
}
|
|
}
|
|
|
|
if ('clickHouse' in destinationConfig) {
|
|
const { url, user, password, database, engine } = destinationConfig.clickHouse
|
|
|
|
return {
|
|
clickhouse: {
|
|
url,
|
|
user,
|
|
password: optionalSecret(password),
|
|
database,
|
|
engine,
|
|
},
|
|
}
|
|
}
|
|
|
|
throw new Error(
|
|
'Invalid destination config: must specify bigQuery, ducklake, snowflake, or clickHouse'
|
|
)
|
|
}
|
|
|
|
export type UpdateDestinationPipelineParams = {
|
|
destinationId: number
|
|
pipelineId: string
|
|
projectRef: string
|
|
destinationName: string
|
|
destinationConfig: DestinationConfig
|
|
sourceId: number
|
|
pipelineConfig: PipelineConfig
|
|
}
|
|
|
|
async function updateDestinationPipeline(
|
|
{
|
|
destinationId: destinationId,
|
|
pipelineId,
|
|
projectRef,
|
|
destinationName: destinationName,
|
|
destinationConfig,
|
|
pipelineConfig,
|
|
sourceId,
|
|
}: UpdateDestinationPipelineParams,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!projectRef) throw new Error('projectRef is required')
|
|
|
|
const destination_config = buildUpdateDestinationApiConfig(destinationConfig)
|
|
|
|
const pipeline_config = buildPipelineApiConfig(pipelineConfig)
|
|
|
|
const { data, error } = await post(
|
|
'/platform/replication/{ref}/destinations-pipelines/{destination_id}/{pipeline_id}',
|
|
{
|
|
params: { path: { ref: projectRef, destination_id: destinationId, pipeline_id: pipelineId } },
|
|
body: {
|
|
destination_config,
|
|
source_id: sourceId,
|
|
destination_name: destinationName,
|
|
pipeline_config,
|
|
},
|
|
signal,
|
|
}
|
|
)
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
type UpdateDestinationPipelineData = Awaited<ReturnType<typeof updateDestinationPipeline>>
|
|
|
|
export const useUpdateDestinationPipelineMutation = ({
|
|
onSuccess,
|
|
onError,
|
|
...options
|
|
}: Omit<
|
|
UseCustomMutationOptions<
|
|
UpdateDestinationPipelineData,
|
|
StudioError,
|
|
UpdateDestinationPipelineParams
|
|
>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation<UpdateDestinationPipelineData, StudioError, UpdateDestinationPipelineParams>({
|
|
mutationFn: (vars) => updateDestinationPipeline(vars),
|
|
async onSuccess(data, variables, context) {
|
|
const { projectRef } = variables
|
|
// These prefixes include list, editor, pipeline status, and table metrics caches.
|
|
await Promise.all([
|
|
queryClient.invalidateQueries({ queryKey: replicationKeys.destinations(projectRef) }),
|
|
invalidateReplicationPipelineQueries(queryClient, projectRef),
|
|
])
|
|
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
// Settings may commit before runtime recreation fails.
|
|
await Promise.all([
|
|
queryClient.invalidateQueries({
|
|
queryKey: replicationKeys.destinations(variables.projectRef),
|
|
}),
|
|
invalidateReplicationPipelineQueries(queryClient, variables.projectRef),
|
|
])
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to update destination or pipeline: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
})
|
|
}
|