-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for getting freshness from DBMS metadata (#8795)
* Add support for getting freshness from DBMS metadata * Add changelog entry * Add simple test case * Change parsing error to warning and add new event type for warning * Code review simplification of capability dict. * Revisions to the capability mechanism per review * Move utility function. * Reduce try/except scope * Clean up imports. * Simplify typing per review * Unit test fix
- Loading branch information
1 parent
bf10a29
commit 2e35426
Showing
17 changed files
with
1,184 additions
and
953 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Allow freshness to be determined via DBMS metadata for supported adapters | ||
time: 2023-10-08T13:43:29.884766-04:00 | ||
custom: | ||
Author: peterallenwebb | ||
Issue: "8704" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from dataclasses import dataclass | ||
from enum import Enum | ||
from typing import Optional, DefaultDict, Mapping | ||
|
||
|
||
class Capability(str, Enum): | ||
"""Enumeration of optional adapter features which can be probed using BaseAdapter.has_feature()""" | ||
|
||
SchemaMetadataByRelations = "SchemaMetadataByRelations" | ||
"""Indicates efficient support for retrieving schema metadata for a list of relations, rather than always retrieving | ||
all the relations in a schema.""" | ||
|
||
TableLastModifiedMetadata = "TableLastModifiedMetadata" | ||
"""Indicates support for determining the time of the last table modification by querying database metadata.""" | ||
|
||
|
||
class Support(str, Enum): | ||
Unknown = "Unknown" | ||
"""The adapter has not declared whether this capability is a feature of the underlying DBMS.""" | ||
|
||
Unsupported = "Unsupported" | ||
"""This capability is not possible with the underlying DBMS, so the adapter does not implement related macros.""" | ||
|
||
NotImplemented = "NotImplemented" | ||
"""This capability is available in the underlying DBMS, but support has not yet been implemented in the adapter.""" | ||
|
||
Versioned = "Versioned" | ||
"""Some versions of the DBMS supported by the adapter support this capability and the adapter has implemented any | ||
macros needed to use it.""" | ||
|
||
Full = "Full" | ||
"""All versions of the DBMS supported by the adapter support this capability and the adapter has implemented any | ||
macros needed to use it.""" | ||
|
||
|
||
@dataclass | ||
class CapabilitySupport: | ||
support: Support | ||
first_version: Optional[str] = None | ||
|
||
def __bool__(self): | ||
return self.support == Support.Versioned or self.support == Support.Full | ||
|
||
|
||
class CapabilityDict(DefaultDict[Capability, CapabilitySupport]): | ||
def __init__(self, vals: Mapping[Capability, CapabilitySupport]): | ||
super().__init__(self._default) | ||
self.update(vals) | ||
|
||
@staticmethod | ||
def _default(): | ||
return CapabilitySupport(support=Support.Unknown) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.