Skip to content

Commit e56326d

Browse files
authored
Disable Spark Catalog caching for integration tests (#501)
1 parent 29fd42c commit e56326d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,7 @@ def spark() -> SparkSession:
19651965
.config("spark.sql.extensions", "org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions")
19661966
.config("spark.sql.catalog.integration", "org.apache.iceberg.spark.SparkCatalog")
19671967
.config("spark.sql.catalog.integration.catalog-impl", "org.apache.iceberg.rest.RESTCatalog")
1968+
.config("spark.sql.catalog.integration.cache-enabled", "false")
19681969
.config("spark.sql.catalog.integration.uri", "http://localhost:8181")
19691970
.config("spark.sql.catalog.integration.io-impl", "org.apache.iceberg.aws.s3.S3FileIO")
19701971
.config("spark.sql.catalog.integration.warehouse", "s3://warehouse/wh/")

tests/integration/test_writes.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,28 @@ def test_data_files(spark: SparkSession, session_catalog: Catalog, arrow_table_w
355355
assert [row.deleted_data_files_count for row in rows] == [0, 0, 1, 0, 0]
356356

357357

358+
@pytest.mark.integration
359+
def test_python_writes_with_spark_snapshot_reads(
360+
spark: SparkSession, session_catalog: Catalog, arrow_table_with_null: pa.Table
361+
) -> None:
362+
identifier = "default.python_writes_with_spark_snapshot_reads"
363+
tbl = _create_table(session_catalog, identifier, {"format-version": "1"}, [])
364+
365+
def get_current_snapshot_id(identifier: str) -> int:
366+
return (
367+
spark.sql(f"SELECT snapshot_id FROM {identifier}.snapshots order by committed_at desc limit 1")
368+
.collect()[0]
369+
.snapshot_id
370+
)
371+
372+
tbl.overwrite(arrow_table_with_null)
373+
assert tbl.current_snapshot().snapshot_id == get_current_snapshot_id(identifier) # type: ignore
374+
tbl.overwrite(arrow_table_with_null)
375+
assert tbl.current_snapshot().snapshot_id == get_current_snapshot_id(identifier) # type: ignore
376+
tbl.append(arrow_table_with_null)
377+
assert tbl.current_snapshot().snapshot_id == get_current_snapshot_id(identifier) # type: ignore
378+
379+
358380
@pytest.mark.integration
359381
@pytest.mark.parametrize("format_version", [1, 2])
360382
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)