You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DuckDB currently does not support dynamic schema creation using variables in DDL statements (e.g., CREATE SCHEMA IF NOT EXISTS ${schema_name}), which creates a significant limitation for runtime-configurable data pipelines managed through the DuckDB CLI.
Use Case
I'm managing a multi-environment data pipeline using DuckDB CLI where configuration is passed at runtime via environment variables. This allows the same pipeline code to operate across development, staging, and production environments with different lakehouse paths, metadata locations, and target schemas.
However, the schema name must currently be hardcoded in SQL:
CREATESCHEMAIF NOT EXISTS bronze; -- Cannot be parameterized
USE bronze;
This breaks the configuration-driven architecture and requires either:
Maintaining separate SQL files per environment
Generating SQL dynamically outside of DuckDB (defeating the purpose of pure SQL pipelines)
Committing environment-specific code
Proposed Solution
Allow schema configuration as part of the DuckLake secret definition, similar to how METADATA_PATH and DATA_PATH are currently configurable:
CREATE OR REPLACE SECRET my_secret (
TYPE ducklake,
METADATA_PATH getvariable('METADATA_PATH'),
DATA_PATH getvariable('PATH_ROOT') ||'/Tables',
SCHEMA getvariable('default_schema') -- New parameter
);
The DuckLake extension would automatically create and use the specified schema when attaching the database.
Benefits & Unblocked Use Cases
This enhancement would unlock:
True environment portability - Single SQL codebase deployable across unlimited environments
Multi-tenant pipelines - Same pipeline code processing data for different tenants/schemas based on runtime configuration
CI/CD integration - Automated testing with dynamic schema isolation without code generation
Simplified deployment - Environment configuration via environment variables only, no code changes
Better separation of concerns - Infrastructure configuration (schemas) separated from business logic (SQL)
Hardcoded conditional logic - doesn't scale across environments
This feature aligns with DuckDB's philosophy of embedding configuration into data source connections (like secrets do for authentication/paths) and would significantly enhance its utility for production data engineering workflows.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Statement
DuckDB currently does not support dynamic schema creation using variables in DDL statements (e.g.,
CREATE SCHEMA IF NOT EXISTS ${schema_name}), which creates a significant limitation for runtime-configurable data pipelines managed through the DuckDB CLI.Use Case
I'm managing a multi-environment data pipeline using DuckDB CLI where configuration is passed at runtime via environment variables. This allows the same pipeline code to operate across development, staging, and production environments with different lakehouse paths, metadata locations, and target schemas.
However, the schema name must currently be hardcoded in SQL:
This breaks the configuration-driven architecture and requires either:
Proposed Solution
Allow schema configuration as part of the DuckLake secret definition, similar to how
METADATA_PATHandDATA_PATHare currently configurable:The DuckLake extension would automatically create and use the specified schema when attaching the database.
Benefits & Unblocked Use Cases
This enhancement would unlock:
Alternative Workarounds (All Suboptimal)
This feature aligns with DuckDB's philosophy of embedding configuration into data source connections (like secrets do for authentication/paths) and would significantly enhance its utility for production data engineering workflows.
Beta Was this translation helpful? Give feedback.
All reactions