Defer get_columns_in_relation when no exposures match in exposure_schema_validity#1014
Conversation
…osures match. Skip warehouse column introspection on the no-exposures path so dbt-fusion BigQuery no longer errors on missing source tables after ADBC get_table_schema. Co-authored-by: Cursor <cursoragent@cursor.com>
|
👋 @elazarlachkar |
📝 WalkthroughWalkthroughThe ChangesDeferred column metadata retrieval
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
macros/edr/tests/test_exposure_schema_validity.sql (1)
29-30: 💤 Low valueOptional: Consider adding a brief inline comment.
The deferred column fetch is a targeted optimization that avoids an unnecessary warehouse call when no exposures match. A brief comment could help future maintainers understand the rationale.
📝 Suggested inline comment
{%- set invalid_exposures = [] -%} {%- if matching_exposures | length > 0 -%} + {# Defer columns fetch until needed; avoids warehouse call when no exposures match #} {%- set columns = columns or adapter.get_columns_in_relation(model) -%}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@macros/edr/tests/test_exposure_schema_validity.sql` around lines 29 - 30, Add a short inline comment explaining why columns are fetched only when matching_exposures has items: next to the conditional using matching_exposures and the set of columns (the line with "{%- if matching_exposures | length > 0 -%}" and "{%- set columns = columns or adapter.get_columns_in_relation(model) -%}"), insert a one-line comment noting this is a deferred optimization to avoid a warehouse call when there are no matching exposures so maintainers understand the rationale.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@macros/edr/tests/test_exposure_schema_validity.sql`:
- Around line 29-30: Add a short inline comment explaining why columns are
fetched only when matching_exposures has items: next to the conditional using
matching_exposures and the set of columns (the line with "{%- if
matching_exposures | length > 0 -%}" and "{%- set columns = columns or
adapter.get_columns_in_relation(model) -%}"), insert a one-line comment noting
this is a deferred optimization to avoid a warehouse call when there are no
matching exposures so maintainers understand the rationale.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ef6d39bc-1716-4684-8090-9ab12a402a66
📒 Files selected for processing (1)
macros/edr/tests/test_exposure_schema_validity.sql
Summary
adapter.get_columns_in_relation(model)inside thematching_exposures | length > 0branch inexposure_schema_validityno_results_query()and never needs column metadataContext
Fusion BigQuery CI fails
test_exposure_schema_validity_no_exposuresbecause dbt-fusion commit 81458a3f switched BigQueryget_columns_in_relationto ADBCget_table_schema()without preserving dbt-core's missing-table → empty-list behavior. The integration test creates a source YAML but does not seed a physical table.This change avoids the unnecessary warehouse call on the no-exposures path while preserving existing validation behavior when exposures do match.
Test plan
test_exposure_schema_validity_no_exposurespassestest_exposure_schema_validity_*cases still pass on other warehousesexposures.yml(customers,orders) still validate columns when exposures matchMade with Cursor
Summary by CodeRabbit