diff --git a/core/dbt/contracts/graph/parsed.py b/core/dbt/contracts/graph/parsed.py index be3ed6d75f1..52c05c3403e 100644 --- a/core/dbt/contracts/graph/parsed.py +++ b/core/dbt/contracts/graph/parsed.py @@ -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): diff --git a/core/dbt/contracts/graph/unparsed.py b/core/dbt/contracts/graph/unparsed.py index d21aecf5172..2cc58683b0d 100644 --- a/core/dbt/contracts/graph/unparsed.py +++ b/core/dbt/contracts/graph/unparsed.py @@ -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): @@ -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) diff --git a/core/dbt/node_runners.py b/core/dbt/node_runners.py index b91fcc44ea2..13a1bcb60af 100644 --- a/core/dbt/node_runners.py +++ b/core/dbt/node_runners.py @@ -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 ) diff --git a/core/dbt/parser/schemas.py b/core/dbt/parser/schemas.py index 0e28fb4ccf6..a94030554bf 100644 --- a/core/dbt/parser/schemas.py +++ b/core/dbt/parser/schemas.py @@ -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( diff --git a/test/integration/042_sources_test/filtered_models/schema.yml b/test/integration/042_sources_test/filtered_models/schema.yml index c4f96f987d7..edad7f6ecfb 100644 --- a/test/integration/042_sources_test/filtered_models/schema.yml +++ b/test/integration/042_sources_test/filtered_models/schema.yml @@ -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 @@ -14,4 +15,4 @@ sources: loaded_at_field: updated_at freshness: error_after: {count: 18, period: hour} - filter: id > 101 + filter: id > 101