|
11 | 11 |
|
12 | 12 | import freezegun
|
13 | 13 | import isodate
|
| 14 | +import pytest |
14 | 15 | from typing_extensions import deprecated
|
15 | 16 |
|
16 | 17 | from airbyte_cdk.models import (
|
@@ -1876,6 +1877,69 @@ def test_stream_using_is_client_side_incremental_has_cursor_state():
|
1876 | 1877 | assert client_side_incremental_cursor_state == expected_cursor_value
|
1877 | 1878 |
|
1878 | 1879 |
|
| 1880 | +@pytest.mark.parametrize( |
| 1881 | + "expected_transform_before_filtering", |
| 1882 | + [ |
| 1883 | + pytest.param( |
| 1884 | + True, |
| 1885 | + id="transform before filtering", |
| 1886 | + ), |
| 1887 | + pytest.param( |
| 1888 | + False, |
| 1889 | + id="transform after filtering", |
| 1890 | + ), |
| 1891 | + pytest.param( |
| 1892 | + None, |
| 1893 | + id="default transform before filtering", |
| 1894 | + ), |
| 1895 | + ], |
| 1896 | +) |
| 1897 | +def test_stream_using_is_client_side_incremental_has_transform_before_filtering_according_to_manifest( |
| 1898 | + expected_transform_before_filtering, |
| 1899 | +): |
| 1900 | + expected_cursor_value = "2024-07-01" |
| 1901 | + state = [ |
| 1902 | + AirbyteStateMessage( |
| 1903 | + type=AirbyteStateType.STREAM, |
| 1904 | + stream=AirbyteStreamState( |
| 1905 | + stream_descriptor=StreamDescriptor(name="locations", namespace=None), |
| 1906 | + stream_state=AirbyteStateBlob(updated_at=expected_cursor_value), |
| 1907 | + ), |
| 1908 | + ) |
| 1909 | + ] |
| 1910 | + |
| 1911 | + manifest_with_stream_state_interpolation = copy.deepcopy(_MANIFEST) |
| 1912 | + |
| 1913 | + # Enable semi-incremental on the locations stream |
| 1914 | + manifest_with_stream_state_interpolation["definitions"]["locations_stream"]["incremental_sync"][ |
| 1915 | + "is_client_side_incremental" |
| 1916 | + ] = True |
| 1917 | + |
| 1918 | + if expected_transform_before_filtering is not None: |
| 1919 | + manifest_with_stream_state_interpolation["definitions"]["locations_stream"]["retriever"][ |
| 1920 | + "record_selector" |
| 1921 | + ]["transform_before_filtering"] = expected_transform_before_filtering |
| 1922 | + |
| 1923 | + source = ConcurrentDeclarativeSource( |
| 1924 | + source_config=manifest_with_stream_state_interpolation, |
| 1925 | + config=_CONFIG, |
| 1926 | + catalog=_CATALOG, |
| 1927 | + state=state, |
| 1928 | + ) |
| 1929 | + concurrent_streams, synchronous_streams = source._group_streams(config=_CONFIG) |
| 1930 | + |
| 1931 | + locations_stream = concurrent_streams[2] |
| 1932 | + assert isinstance(locations_stream, DefaultStream) |
| 1933 | + |
| 1934 | + simple_retriever = locations_stream._stream_partition_generator._partition_factory._retriever |
| 1935 | + record_selector = simple_retriever.record_selector |
| 1936 | + |
| 1937 | + if expected_transform_before_filtering is not None: |
| 1938 | + assert record_selector.transform_before_filtering == expected_transform_before_filtering |
| 1939 | + else: |
| 1940 | + assert record_selector.transform_before_filtering is True |
| 1941 | + |
| 1942 | + |
1879 | 1943 | def create_wrapped_stream(stream: DeclarativeStream) -> Stream:
|
1880 | 1944 | slice_to_records_mapping = get_mocked_read_records_output(stream_name=stream.name)
|
1881 | 1945 |
|
|
0 commit comments