|
29 | 29 | from hive_metastore.ttypes import LockRequest, LockResponse, LockState, UnlockRequest |
30 | 30 | from pyarrow.fs import S3FileSystem |
31 | 31 | from pydantic_core import ValidationError |
| 32 | +from pyspark.sql import SparkSession |
32 | 33 |
|
33 | 34 | from pyiceberg.catalog import Catalog |
34 | 35 | from pyiceberg.catalog.hive import HiveCatalog, _HiveClient |
@@ -1033,3 +1034,31 @@ def test_scan_with_datetime(catalog: Catalog) -> None: |
1033 | 1034 |
|
1034 | 1035 | df = table.scan(row_filter=LessThan("datetime", yesterday)).to_pandas() |
1035 | 1036 | assert len(df) == 0 |
| 1037 | + |
| 1038 | + |
| 1039 | +@pytest.mark.integration |
| 1040 | +# TODO: For Hive we require writing V3 |
| 1041 | +# @pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) |
| 1042 | +@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog")]) |
| 1043 | +def test_initial_default(catalog: Catalog, spark: SparkSession) -> None: |
| 1044 | + identifier = "default.test_initial_default" |
| 1045 | + try: |
| 1046 | + catalog.drop_table(identifier) |
| 1047 | + except NoSuchTableError: |
| 1048 | + pass |
| 1049 | + |
| 1050 | + one_column = pa.table([pa.nulls(10, pa.int32())], names=["some_field"]) |
| 1051 | + |
| 1052 | + tbl = catalog.create_table(identifier, schema=one_column.schema, properties={"format-version": "2"}) |
| 1053 | + |
| 1054 | + tbl.append(one_column) |
| 1055 | + |
| 1056 | + # Do the bump version through Spark, since PyIceberg does not support this (yet) |
| 1057 | + spark.sql(f"ALTER TABLE {identifier} SET TBLPROPERTIES('format-version'='3')") |
| 1058 | + |
| 1059 | + with tbl.update_schema() as upd: |
| 1060 | + upd.add_column("so_true", BooleanType(), required=False, default_value=True) |
| 1061 | + |
| 1062 | + result_table = tbl.scan().filter("so_true == True").to_arrow() |
| 1063 | + |
| 1064 | + assert len(result_table) == 10 |
0 commit comments