soumya-ghosh commented on code in PR #1626:
URL: https://github.com/apache/iceberg-python/pull/1626#discussion_r2079178204
##########
tests/integration/test_inspect_table.py:
##########
@@ -942,3 +949,83 @@ def test_inspect_all_manifests(spark: SparkSession,
session_catalog: Catalog, fo
lhs = spark.table(f"{identifier}.all_manifests").toPandas()
rhs = df.to_pandas()
assert_frame_equal(lhs, rhs, check_dtype=False)
+
+
[email protected]
[email protected]("format_version", [1, 2])
+def test_inspect_all_files(
+ spark: SparkSession, session_catalog: Catalog, arrow_table_with_null:
pa.Table, format_version: int
+) -> None:
+ identifier = "default.table_metadata_files"
+
+ tbl = _create_table(session_catalog, identifier,
properties={"format-version": format_version})
+
+ # append three times
+ for _ in range(3):
+ tbl.append(arrow_table_with_null)
+
+ # configure table properties
+ if format_version == 2:
+ with tbl.transaction() as txn:
+ txn.set_properties({"write.delete.mode": "merge-on-read"})
+ txn.set_properties({"write.update.mode": "merge-on-read"})
+ spark.sql(f"DELETE FROM {identifier} WHERE int = 1")
+ tbl.refresh()
+ tbl.append(arrow_table_with_null)
+ spark.sql(f"UPDATE {identifier} SET string = 'b' WHERE int = 9")
+ spark.sql(f"DELETE FROM {identifier} WHERE int = 1")
+ tbl.refresh()
+
+ all_files_df = tbl.inspect.all_files()
+ all_data_files_df = tbl.inspect.all_data_files()
+ all_delete_files_df = tbl.inspect.all_delete_files()
+
+ _inspect_files_asserts(all_files_df,
spark.table(f"{identifier}.all_files"))
+ _inspect_files_asserts(all_data_files_df,
spark.table(f"{identifier}.all_data_files"))
+ _inspect_files_asserts(all_delete_files_df,
spark.table(f"{identifier}.all_delete_files"))
+
+
[email protected]
+def test_inspect_files_format_version_3(spark: SparkSession, session_catalog:
Catalog, arrow_table_with_null: pa.Table) -> None:
+ identifier = "default.table_metadata_files"
+
+ tbl = _create_table(
+ session_catalog,
+ identifier,
+ properties={
+ "format-version": "3",
+ "write.delete.mode": "merge-on-read",
+ "write.update.mode": "merge-on-read",
+ "write.merge.mode": "merge-on-read",
+ },
+ )
+
+ insert_data_sql = f"""INSERT INTO {identifier} VALUES
+ (false, 'a', 'aaaaaaaaaaaaaaaaaaaaaa', 1, 1, 0.0, 0.0,
TIMESTAMP('2023-01-01 19:25:00'), TIMESTAMP('2023-01-01 19:25:00+00:00'),
DATE('2023-01-01'), X'01', X'00000000000000000000000000000000'),
+ (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL),
+ (true, 'z', 'zzzzzzzzzzzzzzzzzzzzzz', 9, 9, 0.9, 0.9,
TIMESTAMP('2023-03-01 19:25:00'), TIMESTAMP('2023-03-01 19:25:00+00:00'),
DATE('2023-03-01'), X'12', X'11111111111111111111111111111111');
+ """
+
+ spark.sql(insert_data_sql)
+ spark.sql(insert_data_sql)
+ spark.sql(f"UPDATE {identifier} SET int = 2 WHERE int = 1")
+ spark.sql(f"DELETE FROM {identifier} WHERE int = 9")
+ spark.table(identifier).show(20, False)
Review Comment:
Correct, will remove this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]