[dagster-dlt] resolve table names for dynamic tables that use functions#33666
[dagster-dlt] resolve table names for dynamic tables that use functions#33666
Conversation
Greptile SummaryThis PR fixes incorrect runtime metadata in Key changes:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| python_modules/libraries/dagster-dlt/dagster_dlt/resource.py | Core fix looks correct: resolves callable table_name by querying schema.data_tables() with resource name matching; handles single vs multi-root resources properly; rows_loaded and jobs are aggregated across all root tables. Minor: _resolve_child_table_names uses list.pop(0) (O(n)) instead of deque.popleft(); _resolve_root_table_names does not guard against child tables that may carry resource== resource.name (defensive parent check missing). |
| python_modules/libraries/dagster-dlt/dagster_dlt_tests/test_asset_decorator.py | New test correctly exercises the dynamic table_name path and verifies that dagster/table_name and dagster/column_schema are absent for multi-root resources. Only alpha and alpha__values are asserted; beta and beta__values assertions are missing, leaving the second root table path untested. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[extract_resource_metadata called] --> B[_resolve_root_table_names]
B --> C{Any table in schema\nwith resource==resource.name?}
C -- Yes --> D[Return matching table names\ne.g. alpha, beta]
C -- No --> E{table_name callable?}
E -- Yes --> F[Fall back to resource.name]
E -- No --> G[Normalize str table_name]
F --> H[Return normalized fallback name]
G --> H
D --> I{len root_table_names == 1?}
H --> I
I -- Yes, single root --> J[primary_table_name = root_table_names 0]
I -- No, multi-root --> K[primary_table_name = None]
J --> L[supplemental = child tables only]
K --> M[supplemental = root tables + child tables]
L --> N[Emit dagster/column_schema and\ndagster/table_name for primary]
M --> O[No dagster/column_schema or\ndagster/table_name emitted]
N --> P[Emit per-child table schema keys]
O --> Q[Emit per-root and per-child table schema keys]
P --> R[Aggregate rows_loaded across root tables]
Q --> R
R --> S[Filter jobs by root_table_names membership]
S --> T[Return base_metadata]
Reviews (3): Last reviewed commit: "[dagster-dlt] resolve table names for dy..." | Re-trigger Greptile
python_modules/libraries/dagster-dlt/dagster_dlt_tests/test_asset_decorator.py
Show resolved
Hide resolved
|
Followed up on the Greptile notes. Addressed:
Validation:
|
7e400e7 to
39ecb1e
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
@greptileai re-review. |
a371610 to
54ebe04
Compare
|
@greptileai re-review. |
54ebe04 to
0f5924e
Compare
0f5924e to
42a3e2c
Compare

Summary & Motivation
Resolves #21090.
Fixes incorrect runtime metadata in dagster-dlt when a dlt.resource uses a callable table_name and materializes multiple realized tables.
DagsterDltResource.extract_resource_metadata()assumed each dlt resource mapped to a single physical table and derived that table name withstr(resource.table_name). That breaks for resources defined like@dlt.resource(table_name=some_fn), because:str(resource.table_name)becomes a function repr, not a real table name.dagster/column_schemaand no usable table metadata.This was inconsistent with the translator path, which already falls back to resource.name for callable table_name.
This PR updates metadata extraction to use realized dlt schema information instead of assuming a single static table name.
Test Plan
Introduced unit test.
Changelog