-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
102 additions
and
20 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
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
45 changes: 45 additions & 0 deletions
45
airbyte-cdk/python/airbyte_cdk/sources/streams/stream_facade.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,45 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
from typing import Any, Iterable, List, Mapping, Optional, Union | ||
|
||
from airbyte_cdk.models import SyncMode | ||
from airbyte_cdk.sources.streams import Stream | ||
from airbyte_cdk.sources.streams.abstract_stream import AbstractStream | ||
from airbyte_cdk.sources.utils.types import StreamData | ||
|
||
|
||
class StreamFacade(Stream): | ||
def __init__(self, stream: AbstractStream): | ||
self._stream = stream | ||
|
||
@property | ||
def name(self) -> str: | ||
return self._stream.name | ||
|
||
def read_records( | ||
self, | ||
sync_mode: SyncMode, | ||
cursor_field: Optional[List[str]] = None, | ||
stream_slice: Optional[Mapping[str, Any]] = None, | ||
stream_state: Optional[Mapping[str, Any]] = None, | ||
) -> Iterable[StreamData]: | ||
""" | ||
This method should be overridden by subclasses to read records based on the inputs | ||
""" | ||
return self._stream.read() | ||
|
||
@property | ||
def primary_key(self) -> Optional[Union[str, List[str], List[List[str]]]]: | ||
return self._stream | ||
|
||
@property | ||
def cursor_field(self) -> Union[str, List[str]]: | ||
pass | ||
|
||
def get_json_schema(self) -> Mapping[str, Any]: | ||
pass | ||
|
||
@property | ||
def source_defined_cursor(self) -> bool: | ||
pass |
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