Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
7934af2
Improved Semantic expr specification handling (#7876)
QMalcolm Jun 23, 2023
779663b
Improved Semantic Model Measure Percentile defaults (#7877)
QMalcolm Jun 23, 2023
aecbb45
CT-2732: Fix selector methods to include semantic models (#7936)
peterallenwebb Jun 23, 2023
b07ff7a
Bumping version to 1.6.0b6 and generate changelog
FishtownBuildBot Jun 23, 2023
9836f7b
[Automated] Merged prep-release/1.6.0b6_5360267609 into target main d…
FishtownBuildBot Jun 23, 2023
9c97d30
update mashumaro to 3.8.1 (#7951)
gshank Jun 26, 2023
f9d4e9e
Fix comment for `dbt retry` (#7932)
dbeatty10 Jun 26, 2023
b37e5b5
Factor Out Repeated Logic in the PartialParsing Class (#7952)
peterallenwebb Jun 26, 2023
6a1e3a6
Fix macro namespace search packages (#5804)
dbeatty10 Jun 27, 2023
a84fa50
allow setting enabled and depends_on_nodes from ModelNodeArgs (#7930)
MichelleArk Jun 27, 2023
fcd30b1
Set access model node args (#7966)
MichelleArk Jun 27, 2023
7156cc5
Add Partial Parsing Support for Semantic Models (#7964)
peterallenwebb Jun 27, 2023
2ce0c5c
Add merge incremental strategy for postgres (#6951)
rainermensing Jun 28, 2023
036b95e
Handle state:modified for external nodes (#7925)
MichelleArk Jun 28, 2023
b3ac41f
Add thread_id context var (#7942)
NiallRees Jun 28, 2023
22145e7
Add invocation command flag (#7939)
NiallRees Jun 28, 2023
7a6beda
consolidate cross-project ref entrypoint + plugin framework (#7955)
MichelleArk Jun 28, 2023
e01d4c0
Add restrict-access to dbt_project.yml (#7962)
MichelleArk Jun 28, 2023
cb754fd
Bumping version to 1.6.0b7 and generate changelog
FishtownBuildBot Jun 28, 2023
0f52505
Fix CTE insertion position when the model uses WITH RECURSIVE (#7350)…
willbryant Jun 28, 2023
d4e620e
[Automated] Merged prep-release/1.6.0b7_5402737814 into target main d…
FishtownBuildBot Jun 28, 2023
05b0820
Replace space with underscore in NodeType strings (#7947)
jtcohen6 Jun 28, 2023
2e7c968
Use events.contextvar because of multiprocessing unable to pickle Con…
gshank Jun 28, 2023
1af94de
CT-2757: Fix unit test which broke due to merge issues (#7978)
peterallenwebb Jun 28, 2023
5c7aa7f
`dbt clone` (#7881)
aranke Jun 29, 2023
9c6fbff
CT-2707: Populate metric input measures (#7984)
QMalcolm Jun 29, 2023
b8bc264
Unified to UTC (#7665)
d-kaneshiro Jun 29, 2023
8c201e8
type + fix typo in ModelNodeArgs.unique_id (#7992)
MichelleArk Jun 29, 2023
5d93780
Remove pin of sqlparse, minor refactoring, add tests (#7993)
gshank Jun 29, 2023
adcf8bc
[CT-2551] Make state selection MECE (#7773)
trouze Jun 30, 2023
d7d6843
Added note before running integration tests (#7657)
d-kaneshiro Jun 30, 2023
fe463c7
Add time spine table configuration to semantic manifest (#7996)
gshank Jun 30, 2023
7ea51df
allow on_schema_change: fail for incremental models with contracts (#…
MichelleArk Jun 30, 2023
ce07ce5
versioned node selection with underscore delimiting (#7995)
MichelleArk Jun 30, 2023
307a618
Bumping version to 1.6.0b8 and generate changelog
FishtownBuildBot Jun 30, 2023
8ee0fe0
[Automated] Merged prep-release/1.6.0b8_5425945126 into target main d…
FishtownBuildBot Jun 30, 2023
4c44c29
fire proper event for inline query error (#7960)
ChenyuLInx Jun 30, 2023
7fbfd53
CT-2752: Extract methods to new SemanticManifest class for better enc…
peterallenwebb Jul 1, 2023
a58b5ee
CT-2780 [Docs] Fix-toc-links-in-contributing-md (#8017)
gem7318 Jul 5, 2023
746ca7d
Nicer error message for contracted model missing 'columns' (#8024)
jtcohen6 Jul 6, 2023
5d28e47
ModelNodeArgs.unique_id - include v (#8038)
MichelleArk Jul 6, 2023
7c56d72
pin click (#8050)
emmyoop Jul 7, 2023
15ef88d
add workflow for flaky test testing (#8044)
emmyoop Jul 7, 2023
ee7bc24
partial parse file path (#8032)
ChenyuLInx Jul 10, 2023
54b1e56
Update the PR template (#7892)
Jul 10, 2023
44572e7
Semantic Model Validation (#8049)
peterallenwebb Jul 10, 2023
a8e3afe
Fix accidental propagation of log messages to root logger (#7882)
peterallenwebb Jul 11, 2023
a57fdf0
add negative part number test case for split part cross db util (#7200)
dave-connors-3 Jul 11, 2023
7740bd6
Remove `create_metric` as a public facing `SemanticModel.Measure` pro…
QMalcolm Jul 11, 2023
d8f38ca
Flaky Test Workflow (#8055)
emmyoop Jul 11, 2023
fd233ea
Use Ubuntu 22.04.2 LTS (Jammy Jellyfish) since it is a long-term supp…
dbeatty10 Jul 11, 2023
07c3dcd
Fixes #7785: fail-fast behavior (#8066)
aranke Jul 11, 2023
4ffd633
Add validate_sql method to base adapter with implementation for SQLAd…
tlento Jul 11, 2023
b78d23f
Update validate sql test classes to new nomenclature (#8076)
tlento Jul 12, 2023
30def98
Remove volume declaration (#8069)
alexrosenfeld10 Jul 12, 2023
2d686b7
update contributing.md reference to test/integration (#8073)
MichelleArk Jul 12, 2023
305241f
Er/ct 2675 test custom target (#8079)
emmyoop Jul 12, 2023
6604b9c
8030/fix contract checksum (#8072)
MichelleArk Jul 12, 2023
6bdf983
Add semantic_models to tracked resource counts (#8078)
jtcohen6 Jul 12, 2023
5310d37
CT-2691 Fix the populating of a `Metric`'s `depends_on` property (#8…
QMalcolm Jul 12, 2023
be4d0a5
add __test__ = False to non-test classes that start with Test (#8086)
MichelleArk Jul 13, 2023
961d69d
gitignore user.yml and profiles.yml (#8087)
MichelleArk Jul 13, 2023
95a9169
[CT-2821] Support `dbt-semantic-interfaces~=0.1.0rc1` (#8085)
QMalcolm Jul 13, 2023
015c490
Fix query comment tests (#7928) (#7928)
damian3031 Jul 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix macro namespace search packages (dbt-labs#5804)
  • Loading branch information
dbeatty10 authored Jun 27, 2023
commit 6a1e3a6db85f90c682ba5cd124ec28770ae9969a
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20220909-164413.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Fixes
body: Raise better error message when dispatching a package that is not installed
time: 2022-09-09T16:44:13.382685-06:00
custom:
Author: "dbeatty10"
Issue: "5801"
PR: "5804"
36 changes: 21 additions & 15 deletions core/dbt/context/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ def _get_adapter_macro_prefixes(self) -> List[str]:
search_prefixes = get_adapter_type_names(self._adapter.type()) + ["default"]
return search_prefixes

def _get_search_packages(self, namespace: Optional[str] = None) -> List[Optional[str]]:
search_packages: List[Optional[str]] = [None]

if namespace is None:
search_packages = [None]
elif isinstance(namespace, str):
macro_search_order = self._adapter.config.get_macro_search_order(namespace)
if macro_search_order:
search_packages = macro_search_order
elif not macro_search_order and namespace in self._adapter.config.dependencies:
search_packages = [self.config.project_name, namespace]
else:
raise CompilationError(
f"In adapter.dispatch, got a {type(namespace)} macro_namespace argument "
f'("{namespace}"), but macro_namespace should be None or a string.'
)

return search_packages

def dispatch(
self,
macro_name: str,
Expand All @@ -154,20 +173,7 @@ def dispatch(
if packages is not None:
raise MacroDispatchArgError(macro_name)

namespace = macro_namespace

if namespace is None:
search_packages = [None]
elif isinstance(namespace, str):
search_packages = self._adapter.config.get_macro_search_order(namespace)
if not search_packages and namespace in self._adapter.config.dependencies:
search_packages = [self.config.project_name, namespace]
else:
# Not a string and not None so must be a list
raise CompilationError(
f"In adapter.dispatch, got a list macro_namespace argument "
f'("{macro_namespace}"), but macro_namespace should be None or a string.'
)
search_packages = self._get_search_packages(macro_namespace)

attempts = []

Expand All @@ -191,7 +197,7 @@ def dispatch(
return macro

searched = ", ".join(repr(a) for a in attempts)
msg = f"In dispatch: No macro named '{macro_name}' found\n Searched for: {searched}"
msg = f"In dispatch: No macro named '{macro_name}' found within namespace: '{macro_namespace}'\n Searched for: {searched}"
raise CompilationError(msg)


Expand Down
25 changes: 25 additions & 0 deletions tests/functional/macros/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,28 @@
{{ adapter_macro('some_macro', arg1, arg2) }}
{%- endmacro %}
"""

macros__incorrect_dispatch = """
{% macro cowsay() %}
{{ return(adapter.dispatch('cowsay', 'farm_utils')()) }}
{%- endmacro %}

{% macro default__cowsay() %}
'moo'
{% endmacro %}
"""

# Note the difference between `test_utils` below and `farm_utils` above
models__incorrect_dispatch = """
select {{ test_utils.cowsay() }} as cowsay
"""

dbt_project__incorrect_dispatch = """
name: 'test_utils'
version: '1.0'
config-version: 2

profile: 'default'

macro-paths: ["macros"]
"""
41 changes: 41 additions & 0 deletions tests/functional/macros/test_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@
check_relations_equal,
)

from dbt.tests.fixtures.project import write_project_files
from tests.functional.macros.fixtures import (
dbt_project__incorrect_dispatch,
models__dep_macro,
models__with_undefined_macro,
models__local_macro,
models__ref_macro,
models__override_get_columns_macros,
models__deprecated_adapter_macro_model,
models__incorrect_dispatch,
macros__my_macros,
macros__no_default_macros,
macros__override_get_columns_macros,
macros__package_override_get_columns_macros,
macros__deprecated_adapter_macro,
macros__incorrect_dispatch,
)


Expand Down Expand Up @@ -203,6 +207,43 @@ def test_overrides(self, project):
run_dbt()


class TestMisnamedMacroNamespace:
@pytest.fixture(scope="class", autouse=True)
def setUp(self, project_root):
test_utils_files = {
"dbt_project.yml": dbt_project__incorrect_dispatch,
"macros": {
"cowsay.sql": macros__incorrect_dispatch,
},
}
write_project_files(project_root, "test_utils", test_utils_files)

@pytest.fixture(scope="class")
def models(self):
return {
"my_model.sql": models__incorrect_dispatch,
}

@pytest.fixture(scope="class")
def packages(self):
return {
"packages": [
{"local": "test_utils"},
]
}

def test_misnamed_macro_namespace(
self,
project,
):
run_dbt(["deps"])

with pytest.raises(dbt.exceptions.CompilationError) as exc:
run_dbt()

assert "In dispatch: No macro named 'cowsay' found" in str(exc.value)


class TestAdapterMacroDeprecated:
@pytest.fixture(scope="class")
def models(self):
Expand Down