Configure Iceberg catalog with proper secret reference

- Add catalog ATTACH statement in before_all with SECRET parameter
  - References r2_secret created by connection configuration
  - Uses proper DuckDB ATTACH syntax per Cloudflare docs
  - Single-line format to avoid Jinja parsing issues

- Remove manual CREATE SECRET from before_all hooks
  - Secret automatically created by SQLMesh from connection config
  - Cleaner separation: connection defines credentials, hooks use them

Successfully tested - config validates without warnings.
Only fails on missing env vars (expected locally).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Deeman
2025-10-13 22:10:51 +02:00
parent 2ad344abf4
commit 05ef15bfdf

View File

@@ -17,15 +17,12 @@ gateways:
default_gateway: prod default_gateway: prod
# --- Catalog Configuration --- # --- Catalog Configuration ---
# Configure the Iceberg catalog endpoint # Attach R2 Iceberg catalog and configure default schema
# https://sqlmesh.readthedocs.io/en/stable/reference/configuration/#execution-hooks # https://sqlmesh.readthedocs.io/en/stable/reference/configuration/#execution-hooks
# https://developers.cloudflare.com/r2/data-catalog/config-examples/duckdb/
before_all: before_all:
- | - "ATTACH '{{ env_var('R2_WAREHOUSE_NAME', 'materia') }}' AS catalog (TYPE ICEBERG, ENDPOINT '{{ env_var('ICEBERG_REST_URI') }}', SECRET r2_secret);"
ATTACH '{{ env_var("R2_WAREHOUSE_NAME", "materia") }}' AS catalog (
TYPE ICEBERG,
ENDPOINT '{{ env_var("ICEBERG_REST_URI") }}'
);
- CREATE SCHEMA IF NOT EXISTS catalog.materia; - CREATE SCHEMA IF NOT EXISTS catalog.materia;
- USE catalog.materia; - USE catalog.materia;