Skip to content

Commit a83c62f

Browse files
Fix CI and app test
1 parent 373138c commit a83c62f

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

pandas/core/frame.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3574,6 +3574,10 @@ def to_iceberg(
35743574
snapshot_properties : dict of {str: str}, optional
35753575
Custom properties to be added to the snapshot summary
35763576
3577+
Returns
3578+
-------
3579+
None
3580+
35773581
See Also
35783582
--------
35793583
read_iceberg : Read an Apache Iceberg table.
@@ -3582,7 +3586,7 @@ def to_iceberg(
35823586
Examples
35833587
--------
35843588
>>> df = pd.DataFrame(data={"col1": [1, 2], "col2": [4, 3]})
3585-
>>> df.to_iceberg("my_table", catalog_name="my_catalog")
3589+
>>> df.to_iceberg("my_table", catalog_name="my_catalog") # doctest: +SKIP
35863590
"""
35873591
from pandas.io.iceberg import to_iceberg
35883592

pandas/io/iceberg.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
from typing import (
2+
TYPE_CHECKING,
23
Any,
34
)
45

56
from pandas.compat._optional import import_optional_dependency
67

78
from pandas import DataFrame
89

10+
if TYPE_CHECKING:
11+
from pyiceberg.catalog import Catalog # noqa: TC004
912

10-
def _get_catalog(catalog_name: str | None, catalog_properties: dict[str, Any] | None):
13+
14+
def _get_catalog(
15+
catalog_name: str | None, catalog_properties: dict[str, Any] | None
16+
) -> Catalog:
1117
pyiceberg_catalog = import_optional_dependency("pyiceberg.catalog")
1218
if catalog_properties is None:
1319
catalog_properties = {}
@@ -105,7 +111,7 @@ def to_iceberg(
105111
catalog_properties: dict[str, Any] | None = None,
106112
location: str | None = None,
107113
snapshot_properties: dict[str, str] | None = None,
108-
):
114+
) -> None:
109115
"""
110116
Write a DataFrame to an Apache Iceberg table.
111117
@@ -128,11 +134,6 @@ def to_iceberg(
128134
--------
129135
read_iceberg : Read an Apache Iceberg table.
130136
DataFrame.to_parquet : Write a DataFrame in Parquet format.
131-
132-
Examples
133-
--------
134-
>>> df = pd.DataFrame(data={"col1": [1, 2], "col2": [4, 3]})
135-
>>> df.to_iceberg("my_table", catalog_name="my_catalog")
136137
"""
137138
pa = import_optional_dependency("pyarrow")
138139

pandas/tests/io/test_iceberg.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,25 @@ def test_write_by_catalog_name(self, catalog):
177177
catalog_name=catalog.name,
178178
)
179179
tm.assert_frame_equal(result, df)
180+
181+
def test_write_existing_table(self, catalog):
182+
original = read_iceberg(
183+
"ns.my_table",
184+
catalog_properties={"uri": catalog.uri},
185+
)
186+
new = pd.DataFrame(
187+
{
188+
"A": [4, 5],
189+
"B": ["bar", "foobar"],
190+
}
191+
)
192+
new.to_iceberg(
193+
"ns.my_table",
194+
catalog_properties={"uri": catalog.uri},
195+
location=catalog.warehouse,
196+
)
197+
result = read_iceberg(
198+
"ns.my_table",
199+
catalog_properties={"uri": catalog.uri},
200+
)
201+
tm.assert_frame_equal(result, pd.concat([original, new]))

0 commit comments

Comments
 (0)