Skip to content

Commit

Permalink
Separate compiled_path in manifest + printer (#3327)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 authored May 13, 2021
1 parent cfe3636 commit bbab6c2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion core/dbt/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def _write_node(self, node: NonSourceCompiledNode) -> ManifestNode:
logger.debug(f'Writing injected SQL for node "{node.unique_id}"')

if node.compiled_sql:
node.build_path = node.write_node(
node.compiled_path = node.write_node(
self.config.target_path,
'compiled',
node.compiled_sql
Expand Down
1 change: 1 addition & 0 deletions core/dbt/contracts/graph/parsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class ParsedNodeDefaults(ParsedNodeMandatory):
meta: Dict[str, Any] = field(default_factory=dict)
docs: Docs = field(default_factory=Docs)
patch_path: Optional[str] = None
compiled_path: Optional[str] = None
build_path: Optional[str] = None
deferred: bool = False
unrendered_config: Dict[str, Any] = field(default_factory=dict)
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/task/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def print_run_result_error(
with TextOnly():
logger.info("")
logger.info(" compiled SQL at {}".format(
result.node.build_path))
result.node.compiled_path))

elif result.message is not None:
first = True
Expand Down
47 changes: 34 additions & 13 deletions test/integration/029_docs_generate_tests/test_docs_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,8 @@ def expected_seeded_manifest(self, model_database=None, quote_model=False):
'dbt_version': dbt.version.__version__,
'nodes': {
'model.test.model': {
'build_path': Normalized('target/compiled/test/models/model.sql'),
'compiled_path': Normalized('target/compiled/test/models/model.sql'),
'build_path': None,
'name': 'model',
'root_path': self.test_root_realpath,
'relation_name': relation_name_node_format.format(
Expand Down Expand Up @@ -1179,7 +1180,8 @@ def expected_seeded_manifest(self, model_database=None, quote_model=False):
'unrendered_config': unrendered_model_config,
},
'model.test.second_model': {
'build_path': Normalized('target/compiled/test/models/second_model.sql'),
'compiled_path': Normalized('target/compiled/test/models/second_model.sql'),
'build_path': None,
'name': 'second_model',
'root_path': self.test_root_realpath,
'relation_name': relation_name_node_format.format(
Expand Down Expand Up @@ -1256,6 +1258,7 @@ def expected_seeded_manifest(self, model_database=None, quote_model=False):
'unrendered_config': unrendered_second_config
},
'seed.test.seed': {
'compiled_path': None,
'build_path': None,
'compiled': True,
'compiled_sql': '',
Expand Down Expand Up @@ -1335,7 +1338,8 @@ def expected_seeded_manifest(self, model_database=None, quote_model=False):
},
'test.test.not_null_model_id.8ab00aacfe': {
'alias': 'not_null_model_id',
'build_path': Normalized('target/compiled/test/models/schema.yml/schema_test/not_null_model_id.sql'),
'compiled_path': Normalized('target/compiled/test/models/schema.yml/schema_test/not_null_model_id.sql'),
'build_path': None,
'column_name': 'id',
'columns': {},
'config': test_config,
Expand Down Expand Up @@ -1380,6 +1384,7 @@ def expected_seeded_manifest(self, model_database=None, quote_model=False):
},
'snapshot.test.snapshot_seed': {
'alias': 'snapshot_seed',
'compiled_path': None,
'build_path': None,
'checksum': self._checksum_file(snapshot_path),
'columns': {},
Expand Down Expand Up @@ -1422,7 +1427,8 @@ def expected_seeded_manifest(self, model_database=None, quote_model=False):
},
'test.test.test_nothing_model_.596f819934': {
'alias': 'test_nothing_model_',
'build_path': Normalized('target/compiled/test/models/schema.yml/schema_test/test_nothing_model_.sql'),
'compiled_path': Normalized('target/compiled/test/models/schema.yml/schema_test/test_nothing_model_.sql'),
'build_path': None,
'column_name': None,
'columns': {},
'config': test_config,
Expand Down Expand Up @@ -1466,7 +1472,8 @@ def expected_seeded_manifest(self, model_database=None, quote_model=False):
},
'test.test.unique_model_id.3de6fa785f': {
'alias': 'unique_model_id',
'build_path': Normalized('target/compiled/test/models/schema.yml/schema_test/unique_model_id.sql'),
'compiled_path': Normalized('target/compiled/test/models/schema.yml/schema_test/unique_model_id.sql'),
'build_path': None,
'column_name': 'id',
'columns': {},
'config': test_config,
Expand Down Expand Up @@ -1670,7 +1677,8 @@ def expected_postgres_references_manifest(self, model_database=None):
'nodes': {
'model.test.ephemeral_copy': {
'alias': 'ephemeral_copy',
'build_path': Normalized('target/compiled/test/ref_models/ephemeral_copy.sql'),
'compiled_path': Normalized('target/compiled/test/ref_models/ephemeral_copy.sql'),
'build_path': None,
'columns': {},
'config': self.rendered_model_config(materialized='ephemeral'),
'sources': [['my_source', 'my_table']],
Expand Down Expand Up @@ -1709,7 +1717,8 @@ def expected_postgres_references_manifest(self, model_database=None):
},
'model.test.ephemeral_summary': {
'alias': 'ephemeral_summary',
'build_path': Normalized('target/compiled/test/ref_models/ephemeral_summary.sql'),
'compiled_path': Normalized('target/compiled/test/ref_models/ephemeral_summary.sql'),
'build_path': None,
'columns': {
'first_name': {
'description': 'The first name being summarized',
Expand Down Expand Up @@ -1769,7 +1778,8 @@ def expected_postgres_references_manifest(self, model_database=None):
},
'model.test.view_summary': {
'alias': 'view_summary',
'build_path': Normalized('target/compiled/test/ref_models/view_summary.sql'),
'compiled_path': Normalized('target/compiled/test/ref_models/view_summary.sql'),
'build_path': None,
'columns': {
'first_name': {
'description': 'The first name being summarized',
Expand Down Expand Up @@ -1828,6 +1838,7 @@ def expected_postgres_references_manifest(self, model_database=None):
},
'seed.test.seed': {
'alias': 'seed',
'compiled_path': None,
'build_path': None,
'columns': {
'id': {
Expand Down Expand Up @@ -1904,6 +1915,7 @@ def expected_postgres_references_manifest(self, model_database=None):
},
'snapshot.test.snapshot_seed': {
'alias': 'snapshot_seed',
'compiled_path': None,
'build_path': None,
'checksum': self._checksum_file(snapshot_path),
'columns': {},
Expand Down Expand Up @@ -2187,7 +2199,8 @@ def expected_bigquery_complex_manifest(self):
'sources': [],
'depends_on': {'macros': [], 'nodes': ['seed.test.seed']},
'fqn': ['test', 'clustered'],
'build_path': Normalized('target/compiled/test/bq_models/clustered.sql'),
'compiled_path': Normalized('target/compiled/test/bq_models/clustered.sql'),
'build_path': None,
'name': 'clustered',
'original_file_path': clustered_sql_path,
'package_name': 'test',
Expand Down Expand Up @@ -2264,7 +2277,8 @@ def expected_bigquery_complex_manifest(self):
},
'model.test.multi_clustered': {
'alias': 'multi_clustered',
'build_path': Normalized('target/compiled/test/bq_models/multi_clustered.sql'),
'compiled_path': Normalized('target/compiled/test/bq_models/multi_clustered.sql'),
'build_path': None,
'config': self.rendered_model_config(
cluster_by=['first_name', 'email'],
materialized='table',
Expand Down Expand Up @@ -2350,7 +2364,8 @@ def expected_bigquery_complex_manifest(self):
},
'model.test.nested_view': {
'alias': 'nested_view',
'build_path': Normalized('target/compiled/test/bq_models/nested_view.sql'),
'compiled_path': Normalized('target/compiled/test/bq_models/nested_view.sql'),
'build_path': None,
'config': self.rendered_model_config(),
'sources': [],
'depends_on': {
Expand Down Expand Up @@ -2429,7 +2444,8 @@ def expected_bigquery_complex_manifest(self):
},
'model.test.nested_table': {
'alias': 'nested_table',
'build_path': Normalized('target/compiled/test/bq_models/nested_table.sql'),
'compiled_path': Normalized('target/compiled/test/bq_models/nested_table.sql'),
'build_path': None,
'config': self.rendered_model_config(materialized='table'),
'sources': [],
'depends_on': {
Expand Down Expand Up @@ -2466,6 +2482,7 @@ def expected_bigquery_complex_manifest(self):
'unrendered_config': self.unrendered_model_config(materialized='table'),
},
'seed.test.seed': {
'compiled_path': None,
'build_path': None,
'patch_path': self.dir('seed/schema.yml'),
'path': 'seed.csv',
Expand Down Expand Up @@ -2546,6 +2563,7 @@ def expected_bigquery_complex_manifest(self):
},
'snapshot.test.snapshot_seed': {
'alias': 'snapshot_seed',
'compiled_path': None,
'build_path': None,
'checksum': self._checksum_file(snapshot_path),
'columns': {},
Expand Down Expand Up @@ -2657,7 +2675,8 @@ def expected_redshift_incremental_view_manifest(self):
'dbt_version': dbt.version.__version__,
'nodes': {
'model.test.model': {
'build_path': Normalized('target/compiled/test/rs_models/model.sql'),
'compiled_path': Normalized('target/compiled/test/rs_models/model.sql'),
'build_path': None,
'name': 'model',
'root_path': self.test_root_realpath,
'relation_name': '"{0}"."{1}".model'.format(
Expand Down Expand Up @@ -2736,6 +2755,7 @@ def expected_redshift_incremental_view_manifest(self):
'unrendered_config': self.unrendered_model_config(bind=False, materialized='view'),
},
'seed.test.seed': {
'compiled_path': None,
'build_path': None,
'patch_path': self.dir('seed/schema.yml'),
'path': 'seed.csv',
Expand Down Expand Up @@ -2816,6 +2836,7 @@ def expected_redshift_incremental_view_manifest(self):
},
'snapshot.test.snapshot_seed': {
'alias': 'snapshot_seed',
'compiled_path': None,
'build_path': None,
'checksum': self._checksum_file(snapshot_path),
'columns': {},
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'alias', 'tags', 'config', 'unique_id', 'refs', 'sources', 'meta',
'depends_on', 'database', 'schema', 'name', 'resource_type',
'package_name', 'root_path', 'path', 'original_file_path', 'raw_sql',
'description', 'columns', 'fqn', 'build_path', 'patch_path', 'docs',
'description', 'columns', 'fqn', 'build_path', 'compiled_path', 'patch_path', 'docs',
'deferred', 'checksum', 'unrendered_config',
})

Expand Down

0 comments on commit bbab6c2

Please sign in to comment.