Skip to content

Commit 48e933b

Browse files
bindipankhudiBindi Pankhudiaaronsteers
authored
AirbyteLib: Fix no-such-table-error (#35311)
Co-authored-by: Bindi Pankhudi <[email protected]> Co-authored-by: Aaron Steers <[email protected]>
1 parent b05c490 commit 48e933b

File tree

6 files changed

+324
-246
lines changed

6 files changed

+324
-246
lines changed

airbyte-lib/airbyte_lib/_processors.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646

4747
DEFAULT_BATCH_SIZE = 10_000
48+
DEBUG_MODE = False # Set to True to enable additional debug logging.
4849

4950

5051
class BatchHandle:
@@ -60,6 +61,7 @@ class RecordProcessor(abc.ABC):
6061

6162
config_class: type[CacheConfigBase]
6263
skip_finalize_step: bool = False
64+
_expected_streams: set[str]
6365

6466
def __init__(
6567
self,
@@ -109,6 +111,7 @@ def register_source(
109111
incoming_source_catalog=incoming_source_catalog,
110112
incoming_stream_names=stream_names,
111113
)
114+
self._expected_streams = stream_names
112115

113116
@property
114117
def _streams_with_data(self) -> set[str]:
@@ -203,12 +206,18 @@ def process_airbyte_messages(
203206
# Type.LOG, Type.TRACE, Type.CONTROL, etc.
204207
pass
205208

209+
# Add empty streams to the dictionary, so we create a destination table for it
210+
for stream_name in self._expected_streams:
211+
if stream_name not in stream_batches:
212+
if DEBUG_MODE:
213+
print(f"Stream {stream_name} has no data")
214+
stream_batches[stream_name] = []
215+
206216
# We are at the end of the stream. Process whatever else is queued.
207217
for stream_name, stream_batch in stream_batches.items():
208-
if stream_batch:
209-
record_batch = pa.Table.from_pylist(stream_batch)
210-
self._process_batch(stream_name, record_batch)
211-
progress.log_batch_written(stream_name, len(stream_batch))
218+
record_batch = pa.Table.from_pylist(stream_batch)
219+
self._process_batch(stream_name, record_batch)
220+
progress.log_batch_written(stream_name, len(stream_batch))
212221

213222
# Finalize any pending batches
214223
for stream_name in list(self._pending_batches.keys()):

airbyte-lib/examples/run_github.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
source = ab.get_source("source-github")
2020
source.set_config(
2121
{
22-
"repositories": ["airbytehq/quickstarts"],
22+
"repositories": ["airbytehq/airbyte-lib-private-beta"],
2323
"credentials": {"personal_access_token": GITHUB_TOKEN},
2424
}
2525
)
2626
source.check()
27-
source.select_streams(["issues", "pull_requests", "commits", "collaborators"])
27+
source.select_streams(["issues", "pull_requests", "commits", "collaborators", "deployments"])
2828

2929
result = source.read(cache=ab.new_local_cache("github"))
3030
print(result.processed_records)

0 commit comments

Comments
 (0)