Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/0141 regression snapshot freshness #1729

Merged
merged 2 commits into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions core/dbt/contracts/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ def __init__(self, node, max_loaded_at, snapshotted_at,
def failed(self):
return self.status == 'error'

@property
def warned(self):
return self.status == 'warn'

@property
def skipped(self):
return False
Expand Down
1 change: 1 addition & 0 deletions core/dbt/task/freshness.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def build_query(self):
"resource_types": [NodeType.Source],
"tags": [],
"required": ['has_freshness'],
"addin_ephemeral_nodes": False,
}

def get_runner_type(self):
Expand Down
10 changes: 8 additions & 2 deletions core/dbt/ui/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,14 @@ def print_run_result_error(result, newline=True, is_warning=False):
result.node.get('resource_type'),
result.node.get('name'),
result.node.get('original_file_path')))
status = dbt.utils.pluralize(result.status, 'result')
logger.info(" Got {}, expected 0.".format(status))

try:
int(result.status)
except ValueError:
logger.info(" Status: {}".format(result.status))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, but I would organize this like:

try:
    int(result.status)
except ValueError:
    logger.info("  Status: {}".format(result.status))
else:
    status = dbt.utils.pluralize(result.status, 'result')
    logger.info("  Got {}, expected 0.".format(status))

Otherwise uncaught ValueErrors in dbt.utils.pluralize will act as if your int failed.

else:
status = dbt.utils.pluralize(result.status, 'result')
logger.info(" Got {}, expected 0.".format(status))

if result.node.get('build_path') is not None:
logger.info("")
Expand Down
4 changes: 4 additions & 0 deletions test/integration/042_sources_test/models/view_model.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

-- See here: https://github.com/fishtown-analytics/dbt/pull/1729

select * from {{ ref('ephemeral_model') }}
2 changes: 1 addition & 1 deletion test/integration/042_sources_test/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def run_dbt_with_vars(self, cmd, *args, **kwargs):
@use_profile('postgres')
def test_postgres_basic_source_def(self):
results = self.run_dbt_with_vars(['run'])
self.assertEqual(len(results), 3)
self.assertEqual(len(results), 4)
self.assertManyTablesEqual(
['source', 'descendant_model', 'nonsource_descendant'],
['expected_multi_source', 'multi_source_model'])
Expand Down