Scaffold domain digital-core

This commit is contained in:
paul committed 2026-09-17 23:22:37 +12:00
commit 64e0ce27ba
13 files changed
+212

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
# dbt project for the digital-core domain's experience data products.
#
# Runs against the lakehouse as role `dbt`, whose default table access method is
# ducklake, so every model table is DuckLake (Parquet in MinIO), readable through
# Trino as lake.<schema>.<table>. Give each experience product its own schema:
# models/<product_schema>/*.sql with +schema: <product_schema>
#
# By hand: uv run data-domain dbt build
# Scheduled: schedules.yml, registered with platform/domain-integration.sh register mgmt
name: digital_core
version: "1.0.0"
profile: domain
model-paths: ["models"]
macro-paths: ["macros"]
models:
digital_core:
+materialized: table
# Trino reads the lake as `trino`, a member of ducklake_reader.
+grants:
select: ["ducklake_reader"]
on-run-end:
- "{% for schema in schemas %}grant usage on schema {{ schema }} to ducklake_reader;{% endfor %}"
+52
View File
@@ -0,0 +1,52 @@
{#-
Macros that make dbt-postgres work against pg_ducklake. Verified 2026-09-17 with
dbt-core 1.12.5 / dbt-postgres 1.11.0 for table, view and incremental models.
-#}
{#-
dbt-postgres stages incremental rows in `create temporary table ... as`. The dbt role
runs with default_table_access_method = ducklake, and DuckLake tables cannot be
temporary ("temporary tables are not supported with ducklake access method"), so
temporary tables are pinned to heap. Everything else is dbt-postgres's macro verbatim.
-#}
{% macro postgres__create_table_as(temporary, relation, sql) -%}
{%- set unlogged = config.get('unlogged', default=false) -%}
{%- set sql_header = config.get('sql_header', none) -%}
{{ sql_header if sql_header is not none }}
create {% if temporary -%}
temporary
{%- elif unlogged -%}
unlogged
{%- endif %} table {{ relation }}
{% if temporary -%} using heap {%- endif %}
{% set contract_config = config.get('contract') %}
{% if contract_config.enforced %}
{{ get_assert_columns_equivalent(sql) }}
{% endif -%}
{% if contract_config.enforced and (not temporary) -%}
{{ get_table_columns_and_constraints() }} ;
insert into {{ relation }} (
{{ adapter.dispatch('get_column_names', 'dbt')() }}
)
{%- set sql = get_select_subquery(sql) %}
{% else %}
as
{% endif %}
(
{{ sql }}
);
{%- endmacro %}
{#-
A model's +schema is its experience product's schema, used as given rather than
prefixed with the target schema, so the product reads as lake.<schema>.<table>.
-#}
{% macro generate_schema_name(custom_schema_name, node) -%}
{%- if custom_schema_name is none -%}
{{ target.schema }}
{%- else -%}
{{ custom_schema_name | trim }}
{%- endif -%}
{%- endmacro %}
View File
Whitespace-only changes.
+16
View File
@@ -0,0 +1,16 @@
# dbt connection profile, read inside the dbt-worker container.
# DBT_PASSWORD comes from the domain's .env; nothing else leaves the domain.
domain:
target: lakehouse
outputs:
lakehouse:
type: postgres
host: lakehouse
port: 5432
user: dbt
password: "{{ env_var('DBT_PASSWORD') }}"
dbname: lake
schema: experience
# DuckLake does not retry conflicting transactions. On a first run dbt creates
# schemas from several threads at once, and two creating the same schema abort.
threads: 1
+9
View File
@@ -0,0 +1,9 @@
# dbt schedules for domain digital-core: one Airflow DAG per entry, run by this domain's
# dbt-worker (platform/airflow/dbt_dags.py). The management zone's Airflow reads a copy,
# so re-run `platform/domain-integration.sh register mgmt` after editing this file.
domain: digital-core
schedules: []
# - name: experience-hourly # DAG id: dbt_digital_core_experience_hourly
# select: tag:hourly # dbt node selection
# schedule: "@hourly" # cron or preset; null for manual runs only
# description: Rebuild the experience products tagged hourly