Skip to content

Conversation

@vchan
Copy link
Contributor

@vchan vchan commented Sep 27, 2025

This PR:

  • Makes the dispatch mapping from a project config available to the adapter via jinja globals
  • Updates the adapter's dispatch function to use search_order if configured
  • Refactors prefix resolution

@vchan vchan requested a review from Copilot September 27, 2025 01:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements support for dbt macro dispatch search order, allowing projects to customize the order in which packages are searched when resolving macros through the adapter.dispatch() function.

  • Adds support for the dispatch configuration in dbt_project.yml files
  • Updates the adapter dispatch logic to respect custom search orders
  • Adds comprehensive test fixtures and test cases to verify the functionality

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sqlmesh/dbt/package.py Adds dispatch field to Package model and loads dispatch config from project YAML
sqlmesh/dbt/loader.py Integrates dispatch configuration into the project loading process
sqlmesh/dbt/context.py Adds dispatch storage and access methods to DbtContext
sqlmesh/dbt/adapter.py Refactors dispatch method to use custom search orders from configuration
tests/dbt/test_adapter.py Adds new test cases to verify dispatch search order functionality
Multiple test fixture files Creates comprehensive test setup with packages, macros, and dispatch configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@vchan vchan marked this pull request as ready for review September 29, 2025 17:35
if candidates:
sorted_candidates = sorted(candidates, key=_relevance)
return candidates[sorted_candidates[0]]
for prefix in (f"{target_type}__", "default__", ""):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the empty string needed? I might be wrong but also looking at the docs when dbt doesn't find either the adapter or namespace in dispatch it always falls back to default__ as prefix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants