diff --git a/core/dbt/context/context_config.py b/core/dbt/context/context_config.py index 611693b29e3..b79ae307fa6 100644 --- a/core/dbt/context/context_config.py +++ b/core/dbt/context/context_config.py @@ -148,8 +148,6 @@ def calculate_node_config( ) -> BaseConfig: own_config = self.get_node_project(project_name) result = self.initial_result(resource_type=resource_type, base=base) - if "_dbt_node_type_configs" in config_call_dict: - result = self._update_from_config(result, config_call_dict["_dbt_node_type_configs"]) project_configs = self._project_configs(own_config, fqn, resource_type) for fqn_config in project_configs: @@ -163,9 +161,6 @@ def calculate_node_config( # config_calls are created in the 'experimental' model parser and # the ParseConfigObject (via add_config_call) - config_call_dict = { - k: config_call_dict[k] for k in config_call_dict.keys() - {"_dbt_node_type_configs"} - } result = self._update_from_config(result, config_call_dict) if own_config.project_name != self._active_project.project_name: @@ -197,7 +192,6 @@ def get_config_source(self, project: Project) -> ConfigSource: def initial_result(self, resource_type: NodeType, base: bool) -> C: # defaults, own_config, config calls, active_config (if != own_config) - # aqui vai puxar o node config com default view config_cls = get_config_for(resource_type, base=base) # Calculate the defaults. We don't want to validate the defaults, # because it might be invalid in the case of required config members diff --git a/core/dbt/parser/base.py b/core/dbt/parser/base.py index 89764a7724b..35c5c8c1cff 100644 --- a/core/dbt/parser/base.py +++ b/core/dbt/parser/base.py @@ -222,11 +222,6 @@ def _create_parsetime_node( name = block.name if block.path.relative_path.endswith(".py"): language = ModelLanguage.python - config.add_config_call( - { - "_dbt_node_type_configs": {"materialized": "table"}, - } - ) else: # this is not ideal but we have a lot of tests to adjust if don't do it language = ModelLanguage.sql @@ -310,6 +305,22 @@ def update_parsed_node_relation_names( self._update_node_relation_name(parsed_node) + def normalize_model_node(sellf, parsed_node: IntermediateNode) -> None: + """This normalize the config for a model node. + + The default materialization for a model is a view, but it's not + supported by python models. This function changes the default view to + table for python models. + """ + if not parsed_node.resource_type == NodeType.Model: + return None + + if not parsed_node.language == ModelLanguage.python: + return None + + if parsed_node.config.materialized == "view": + parsed_node.config.materialized = "table" + def update_parsed_node_config( self, parsed_node: FinalNode, @@ -327,6 +338,7 @@ def update_parsed_node_config( # and calls calculate_node_config to combine dbt_project configs and # config calls from SQL files, plus patch configs (from schema files) config_dict = config.build_config_dict(patch_config_dict=patch_config_dict) + self.normalize_model_node(parsed_node) # Set tags on node provided in config blocks. Tags are additive, so even if # config has been built before, we don't have to reset tags in the parsed_node. diff --git a/tests/unit/parser/test_parser.py b/tests/unit/parser/test_parser.py index f595ac41e83..d89bd12ea53 100644 --- a/tests/unit/parser/test_parser.py +++ b/tests/unit/parser/test_parser.py @@ -1085,7 +1085,6 @@ def test_python_model_parse(self): config_call_dict={ "materialized": "table", "packages": python_packages, - "_dbt_node_type_configs": {"materialized": "table"}, }, refs=[ RefArgs(name="a_model"),