airbyte_cdk.sources.declarative.partition_routers.partition_router

 1#
 2# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
 3#
 4
 5from abc import abstractmethod
 6from dataclasses import dataclass
 7from typing import Mapping, Optional
 8
 9from airbyte_cdk.sources.declarative.stream_slicers.stream_slicer import StreamSlicer
10from airbyte_cdk.sources.types import StreamState
11
12
13@dataclass
14class PartitionRouter(StreamSlicer):
15    """
16    Base class for partition routers.
17    Methods:
18        get_stream_state(): Get the state of the parent streams.
19    """
20
21    @abstractmethod
22    def get_stream_state(self) -> Optional[Mapping[str, StreamState]]:
23        """
24        Get the state of the parent streams.
25
26        This method should only be implemented if the slicer is based on some parent stream and needs to read this stream
27        incrementally using the state.
28
29        Returns:
30            Optional[Mapping[str, StreamState]]: The current state of the parent streams in a dictionary format.
31                 The returned format will be:
32                 {
33                     "parent_stream_name1": {
34                         "last_updated": "2023-05-27T00:00:00Z"
35                     },
36                     "parent_stream_name2": {
37                         "last_updated": "2023-05-27T00:00:00Z"
38                     }
39                 }
40        """
@dataclass
class PartitionRouter(airbyte_cdk.sources.declarative.stream_slicers.stream_slicer.StreamSlicer):
14@dataclass
15class PartitionRouter(StreamSlicer):
16    """
17    Base class for partition routers.
18    Methods:
19        get_stream_state(): Get the state of the parent streams.
20    """
21
22    @abstractmethod
23    def get_stream_state(self) -> Optional[Mapping[str, StreamState]]:
24        """
25        Get the state of the parent streams.
26
27        This method should only be implemented if the slicer is based on some parent stream and needs to read this stream
28        incrementally using the state.
29
30        Returns:
31            Optional[Mapping[str, StreamState]]: The current state of the parent streams in a dictionary format.
32                 The returned format will be:
33                 {
34                     "parent_stream_name1": {
35                         "last_updated": "2023-05-27T00:00:00Z"
36                     },
37                     "parent_stream_name2": {
38                         "last_updated": "2023-05-27T00:00:00Z"
39                     }
40                 }
41        """

Base class for partition routers.

Methods:

get_stream_state(): Get the state of the parent streams.

@abstractmethod
def get_stream_state(self) -> Optional[Mapping[str, Mapping[str, Any]]]:
22    @abstractmethod
23    def get_stream_state(self) -> Optional[Mapping[str, StreamState]]:
24        """
25        Get the state of the parent streams.
26
27        This method should only be implemented if the slicer is based on some parent stream and needs to read this stream
28        incrementally using the state.
29
30        Returns:
31            Optional[Mapping[str, StreamState]]: The current state of the parent streams in a dictionary format.
32                 The returned format will be:
33                 {
34                     "parent_stream_name1": {
35                         "last_updated": "2023-05-27T00:00:00Z"
36                     },
37                     "parent_stream_name2": {
38                         "last_updated": "2023-05-27T00:00:00Z"
39                     }
40                 }
41        """

Get the state of the parent streams.

This method should only be implemented if the slicer is based on some parent stream and needs to read this stream incrementally using the state.

Returns:

Optional[Mapping[str, StreamState]]: The current state of the parent streams in a dictionary format. The returned format will be: { "parent_stream_name1": { "last_updated": "2023-05-27T00:00:00Z" }, "parent_stream_name2": { "last_updated": "2023-05-27T00:00:00Z" } }