From e46aca8ca24c98eb83bf0de74d5b9b79ea2ed6f0 Mon Sep 17 00:00:00 2001 From: Seher Karakuzu Date: Wed, 13 Mar 2024 16:24:55 -0400 Subject: [PATCH] added an integration test for the new append method --- tiled/_tests/test_writing.py | 29 +++++++++++++++++++++++++++++ tiled/client/dataframe.py | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tiled/_tests/test_writing.py b/tiled/_tests/test_writing.py index 0f3f0704d..45e31e8f9 100644 --- a/tiled/_tests/test_writing.py +++ b/tiled/_tests/test_writing.py @@ -489,3 +489,32 @@ def test_write_with_specified_mimetype(tree): ), ], ) + + +def test_append_partition(tree): + with Context.from_app(build_app(tree)) as context: + client = from_context(context, include_data_sources=True) + df = pandas.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}) + structure = TableStructure.from_pandas(df) + + x = client.new( + "table", + [ + DataSource( + structure_family="table", + structure=structure, + mimetype="text/csv", + ), + ], + key="x", + ) + x.write(df) + + df2 = pandas.DataFrame({"A": [11, 12, 13], "B": [14, 15, 16]}) + + x.append_partition(df2, 0) + df3 = pandas.DataFrame({"A": [1, 2, 3, 11, 12, 13], "B": [4, 5, 6, 14, 15, 16]}) + + assert [row for col in x.columns for row in x[col]] == [ + row for col in df3.columns for row in df3[col] + ] diff --git a/tiled/client/dataframe.py b/tiled/client/dataframe.py index b02e5786a..7c533cabd 100644 --- a/tiled/client/dataframe.py +++ b/tiled/client/dataframe.py @@ -229,7 +229,7 @@ def append_partition(self, dataframe, partition): headers={"Content-Type": APACHE_ARROW_FILE_MIME_TYPE}, ) ) - + def export(self, filepath, columns=None, *, format=None): """ Download data in some format and write to a file.