Skip to content

Commit 025c511

Browse files
committed
I/O: Apache Iceberg (implement suggestions by CodeRabbit)
1 parent a3d7292 commit 025c511

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

cratedb_toolkit/cluster/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ def save_table(
657657
from cratedb_toolkit.io.iceberg import to_iceberg
658658

659659
if not to_iceberg(source_url, target.url):
660-
raise IOError("Data loading failed or incomplete")
660+
raise OperationFailed("Data loading failed or incomplete")
661661

662662
else:
663663
raise NotImplementedError(f"Exporting resource not implemented yet: {target_url_obj}")

cratedb_toolkit/io/iceberg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def catalog_properties(self):
103103
}
104104
prefixes = ["dynamodb.", "gcp.", "glue."]
105105
opts.update(self.collect_properties(self.url.query_params, prefixes))
106-
return opts
106+
return {k: v for k, v in opts.items() if v is not None}
107107

108108
@property
109109
def storage_options(self):
@@ -187,12 +187,12 @@ def from_iceberg(source_url, target_url, progress: bool = False):
187187
# user-specified `if_exists`, but subsequent batches must use "append".
188188
with pl.Config(streaming_chunk_size=chunksize):
189189
table = iceberg_address.load_table()
190-
for batch in table.collect_batches(engine="streaming", chunk_size=chunksize):
190+
for i, batch in enumerate(table.collect_batches(engine="streaming", chunk_size=chunksize)):
191191
batch.to_pandas().to_sql(
192192
name=cratedb_table.table,
193193
schema=cratedb_table.schema,
194194
con=engine,
195-
if_exists=if_exists,
195+
if_exists=if_exists if i == 0 else "append",
196196
index=False,
197197
chunksize=chunksize,
198198
method=insert_bulk,

0 commit comments

Comments
 (0)