-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dagster-fivetran] Implement FivetranEventIterator
- Loading branch information
1 parent
0655395
commit 969b992
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
python_modules/libraries/dagster-fivetran/dagster_fivetran/fivetran_event_iterator.py
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,32 @@ | ||
from collections import abc | ||
from typing import TYPE_CHECKING, Generic, Iterator, Union | ||
|
||
from dagster import AssetMaterialization, MaterializeResult | ||
from typing_extensions import TypeVar | ||
|
||
if TYPE_CHECKING: | ||
from dagster_fivetran.resources import FivetranWorkspace | ||
|
||
|
||
FivetranEventType = Union[AssetMaterialization, MaterializeResult] | ||
T = TypeVar("T", bound=FivetranEventType) | ||
|
||
|
||
class FivetranEventIterator(Generic[T], abc.Iterator): | ||
"""A wrapper around an iterator of Fivetran events which contains additional methods for | ||
post-processing the events, such as fetching column metadata. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
events: Iterator[T], | ||
fivetran_workspace: "FivetranWorkspace", | ||
) -> None: | ||
self._inner_iterator = events | ||
self._fivetran_workspace = fivetran_workspace | ||
|
||
def __next__(self) -> T: | ||
return next(self._inner_iterator) | ||
|
||
def __iter__(self) -> "FivetranEventIterator[T]": | ||
return self |
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