|
4 | 4 | import json |
5 | 5 | import warnings |
6 | 6 | from pathlib import Path |
7 | | -from typing import TYPE_CHECKING, Any, cast |
| 7 | +from typing import TYPE_CHECKING, Any, Optional, cast |
8 | 8 |
|
9 | 9 | import jsonschema |
10 | 10 | import pendulum |
@@ -222,6 +222,14 @@ def get_available_streams(self) -> list[str]: |
222 | 222 | """Get the available streams from the spec.""" |
223 | 223 | return [s.name for s in self.discovered_catalog.streams] |
224 | 224 |
|
| 225 | + def _get_incremental_stream_names(self) -> list[str]: |
| 226 | + """Get the name of streams that support incremental sync.""" |
| 227 | + return [ |
| 228 | + stream.name |
| 229 | + for stream in self.discovered_catalog.streams |
| 230 | + if SyncMode.incremental in stream.supported_sync_modes |
| 231 | + ] |
| 232 | + |
225 | 233 | def _get_spec(self, *, force_refresh: bool = False) -> ConnectorSpecification: |
226 | 234 | """Call spec on the connector. |
227 | 235 |
|
@@ -624,6 +632,19 @@ def _log_sync_start( |
624 | 632 | event_type=EventType.SYNC, |
625 | 633 | ) |
626 | 634 |
|
| 635 | + def _log_incremental_streams( |
| 636 | + self, |
| 637 | + *, |
| 638 | + incremental_streams: Optional[set[str]] = None, |
| 639 | + ) -> None: |
| 640 | + """Log the streams which are using incremental sync mode.""" |
| 641 | + log_message = ( |
| 642 | + "The following streams are currently using incremental sync:\n" |
| 643 | + f"{incremental_streams}\n" |
| 644 | + "To perform a full refresh, set 'force_full_refresh=True' in 'airbyte.read()' method." |
| 645 | + ) |
| 646 | + print(log_message) |
| 647 | + |
627 | 648 | def _log_stream_read_start(self, stream: str) -> None: |
628 | 649 | print(f"Read started on stream: {stream} at {pendulum.now().format('HH:mm:ss')}...") |
629 | 650 |
|
@@ -737,6 +758,17 @@ def read( |
737 | 758 |
|
738 | 759 | self._log_sync_start(cache=cache) |
739 | 760 |
|
| 761 | + # Log incremental stream if incremental streams are known |
| 762 | + if state_provider and state_provider.known_stream_names: |
| 763 | + # Retrieve set of the known streams support which support incremental sync |
| 764 | + incremental_streams = ( |
| 765 | + set(self._get_incremental_stream_names()) |
| 766 | + & state_provider.known_stream_names |
| 767 | + & set(self.get_selected_streams()) |
| 768 | + ) |
| 769 | + if incremental_streams: |
| 770 | + self._log_incremental_streams(incremental_streams=incremental_streams) |
| 771 | + |
740 | 772 | cache_processor = cache.get_record_processor( |
741 | 773 | source_name=self.name, |
742 | 774 | catalog_provider=CatalogProvider(self.configured_catalog), |
|
0 commit comments