Skip to content

Commit

Permalink
hoist filter into the freshness settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Beck committed Sep 24, 2019
1 parent 2799a8c commit 55a6b9a
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion core/dbt/contracts/graph/parsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ class ParsedSourceDefinition(
docrefs: List[Docref] = field(default_factory=list)
description: str = ''
columns: Dict[str, ColumnInfo] = field(default_factory=dict)
filter: Optional[str] = None

@property
def is_ephemeral_model(self):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/contracts/graph/unparsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class FreshnessStatus(StrEnum):
class FreshnessThreshold(JsonSchemaMixin, Mergeable):
warn_after: Optional[Time] = None
error_after: Optional[Time] = None
filter: Optional[str] = None

def status(self, age: float) -> FreshnessStatus:
if self.error_after and self.error_after.exceeded(age):
Expand Down Expand Up @@ -133,7 +134,6 @@ class UnparsedSourceTableDefinition(ColumnDescription, NodeDescription):
freshness: Optional[FreshnessThreshold] = field(
default_factory=FreshnessThreshold
)
filter: Optional[str] = None

def __post_init__(self):
NodeDescription.__post_init__(self)
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/node_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def execute(self, compiled_node, manifest):
freshness = self.adapter.calculate_freshness(
relation,
compiled_node.loaded_at_field,
compiled_node.filter,
compiled_node.freshness.filter,
manifest=manifest
)

Expand Down
1 change: 0 additions & 1 deletion core/dbt/parser/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ def generate_source_node(
quoting=quoting,
resource_type=SourceType(NodeType.Source),
fqn=[self.project.project_name, source.name, table.name],
filter=table.filter,
)

def generate_node_patch(
Expand Down
3 changes: 2 additions & 1 deletion test/integration/042_sources_test/filtered_models/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sources:
freshness:
warn_after: {count: 10, period: hour}
error_after: {count: 1, period: day}
filter: id > 1
schema: "{{ var(env_var('DBT_TEST_SCHEMA_NAME_VARIABLE')) }}"
quoting:
identifier: True
Expand All @@ -14,4 +15,4 @@ sources:
loaded_at_field: updated_at
freshness:
error_after: {count: 18, period: hour}
filter: id > 101
filter: id > 101

0 comments on commit 55a6b9a

Please sign in to comment.