import type { DuckDBConnection } from '@duckdb/node-api'; import { type SQLWrapper } from 'drizzle-orm'; import { type SQL } from 'drizzle-orm/sql/sql'; import type { DuckDBConnectionPool } from './client.ts'; import { type DuckDBPoolConfig, type PoolPreset } from './pool.ts'; export interface DuckLakeAttachOptions { createIfNotExists?: boolean; dataInliningRowLimit?: number; dataPath?: string; encrypted?: boolean; /** * @deprecated DuckLake has no `META_PARAMETER_NAME` option, so this setting * always failed the ATTACH. Setting it now throws. Use `metaParameters`. */ metaParameterName?: string; /** * Options passed to the metadata catalog. Each entry becomes * `META_ 'value'`, so `{ type: 'duckdb' }` emits `META_TYPE 'duckdb'`. */ metaParameters?: Record; metadataCatalog?: string; overrideDataPath?: boolean; readOnly?: boolean; } export interface DuckLakeConfig { catalog: string; alias?: string; use?: boolean; install?: boolean; load?: boolean; attachOptions?: DuckLakeAttachOptions; } export interface NormalizedDuckLakeConfig { catalog: string; alias: string; use: boolean; install: boolean; load: boolean; attachOptions?: DuckLakeAttachOptions; } export interface DuckLakePoolResolution { poolSize: number | false; resolvedPoolSize: number | false; isLocalCatalog: boolean; hasPoolSetting: boolean; } export declare function normalizeDuckLakeConfig(config: DuckLakeConfig): NormalizedDuckLakeConfig; export declare function buildDuckLakeAttachSql(config: DuckLakeConfig): string; export declare function configureDuckLake(connection: DuckDBConnection, config: DuckLakeConfig): Promise; /** * Returns a per-connection setup hook for connections that share one DuckDB * instance. Concurrent ATTACH IF NOT EXISTS calls can both miss the existing * catalog, so setup runs one connection at a time. */ export declare function createDuckLakeConnectionSetup(config: DuckLakeConfig): (connection: DuckDBConnection) => Promise; export declare function wrapDuckLakePool(pool: DuckDBConnectionPool, config: DuckLakeConfig): DuckDBConnectionPool; /** * Reports whether a DuckLake catalog is a local DuckDB file. `duckdb:` and * `file:` catalogs and strings without a scheme that look like a path are * local. Other schemes such as `md:`, `s3:` or `postgres:` are not. DuckLake * reads a bare name such as `my_lake` as a secret name, so it is not treated as * a local file. */ export declare function isDuckDbFileCatalog(catalog: string): boolean; export declare function resolveDuckLakePoolSize(poolSetting: DuckDBPoolConfig | PoolPreset | false | undefined, ducklakeConfig: DuckLakeConfig | undefined): DuckLakePoolResolution; export interface DuckLakeMergeAdjacentFilesOptions { /** Only compact this table. */ table?: string | SQLWrapper; /** Schema of `table`. */ schema?: string | SQLWrapper; minFileSize?: number | bigint | SQLWrapper; maxFileSize?: number | bigint | SQLWrapper; maxCompactedFiles?: number | bigint | SQLWrapper; /** * Only merge files written at or after this time. MotherDuck DuckLake * supports it. The DuckLake extension that ships for DuckDB 1.5.6 does not. */ newerThan?: Date | string | SQLWrapper; /** Only merge files written before this time. Same support as `newerThan`. */ olderThan?: Date | string | SQLWrapper; } /** One row per compacted table. DuckLake for DuckDB 1.4 returns no rows. */ export type DuckLakeMergeAdjacentFilesRow = { schema_name: string; table_name: string; files_processed: number | bigint; files_created: number | bigint; }; /** * Build `ducklake_merge_adjacent_files` to compact small adjacent data files. * Use it as a table source, as in `select * from ${duckLakeMergeAdjacentFiles('lake')}`. */ export declare function duckLakeMergeAdjacentFiles(catalog: string | SQLWrapper, options?: DuckLakeMergeAdjacentFilesOptions): SQL;