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

TableLastModifiedMetadataBatch capability #744

Merged
merged 12 commits into from
Apr 18, 2024
16 changes: 14 additions & 2 deletions dbt/adapters/redshift/impl.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import os
from dataclasses import dataclass
from dbt_common.contracts.constraints import ConstraintType
from typing import Optional, Set, Any, Dict, Type
from typing import Optional, Set, Any, Dict, Type, List, Tuple
from collections import namedtuple
from dbt.adapters.base import PythonJobHelper
from dbt.adapters.base.impl import AdapterConfig, ConstraintSupport
from dbt.adapters.base.impl import AdapterConfig, ConstraintSupport, FreshnessResponse
from dbt.adapters.base.meta import available
from dbt.adapters.base.relation import BaseRelation
from dbt.adapters.capability import Capability, CapabilityDict, CapabilitySupport, Support
from dbt.adapters.contracts.macros import MacroResolverProtocol
from dbt.adapters.sql import SQLAdapter
from dbt.adapters.contracts.connection import AdapterResponse
from dbt.adapters.events.logging import AdapterLogger
Expand Down Expand Up @@ -58,6 +60,7 @@ class RedshiftAdapter(SQLAdapter):
{
Capability.SchemaMetadataByRelations: CapabilitySupport(support=Support.Full),
Capability.TableLastModifiedMetadata: CapabilitySupport(support=Support.Full),
Capability.TableLastModifiedMetadataBatch: CapabilitySupport(support=Support.Full),
}
)

Expand Down Expand Up @@ -183,3 +186,12 @@ def generate_python_submission_response(self, submission_result: Any) -> Adapter
def debug_query(self):
"""Override for DebugTask method"""
self.execute("select 1 as id")

def calculate_freshness_from_metadata_batch(
self,
sources: List[BaseRelation],
macro_resolver: Optional[MacroResolverProtocol] = None,
) -> Tuple[List[Optional[AdapterResponse]], Dict[BaseRelation, FreshnessResponse]]:
conn = self.connections.get_if_exists()
self.connections.open(conn)
return super().calculate_freshness_from_metadata_batch(sources, macro_resolver)
6 changes: 3 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# install latest changes in dbt-core + dbt-postgres
git+https://github.com/dbt-labs/dbt-adapters.git
git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter
git+https://github.com/dbt-labs/dbt-adapters.git@batch-metadata-freshness
git+https://github.com/dbt-labs/dbt-adapters.git@batch-metadata-freshness#subdirectory=dbt-tests-adapter
git+https://github.com/dbt-labs/dbt-common.git
git+https://github.com/dbt-labs/dbt-core.git#subdirectory=core
git+https://github.com/dbt-labs/dbt-core.git@batch-metadata-freshness#subdirectory=core
git+https://github.com/dbt-labs/dbt-postgres.git

# if version 1.x or greater -> pin to major version
Expand Down
Loading