|
34 | 34 | from pyiceberg.expressions.literals import literal |
35 | 35 | from pyiceberg.io.pyarrow import ( |
36 | 36 | UnsupportedPyArrowTypeException, |
| 37 | + _check_pyarrow_schema_compatible, |
37 | 38 | _ConvertToArrowSchema, |
38 | 39 | _ConvertToIceberg, |
39 | 40 | _ConvertToIcebergWithoutIDs, |
@@ -313,6 +314,28 @@ def test_pyarrow_dictionary_encoded_type_to_iceberg(value_type: pa.DataType, exp |
313 | 314 | assert visit_pyarrow(pyarrow_dict, _ConvertToIceberg()) == expected_result |
314 | 315 |
|
315 | 316 |
|
| 317 | +def test_schema_check_null_column(table_schema_simple: Schema) -> None: |
| 318 | + pyarrow_schema: pa.Schema = schema_to_pyarrow(table_schema_simple) |
| 319 | + new_field = pyarrow_schema.field(0).with_type(pa.null()) # Make the optional string field null for testing |
| 320 | + pyarrow_schema = pyarrow_schema.set(0, new_field) |
| 321 | + assert pyarrow_schema.field(0).type == pa.null() |
| 322 | + _check_pyarrow_schema_compatible(table_schema_simple, pyarrow_schema) |
| 323 | + |
| 324 | + |
| 325 | +def test_schema_conversion_null_column(table_schema_simple: Schema) -> None: |
| 326 | + pyarrow_schema: pa.Schema = schema_to_pyarrow(table_schema_simple) |
| 327 | + new_field = pyarrow_schema.field(2).with_type(pa.null()) # Make the optional boolean field null for testing |
| 328 | + pyarrow_schema = pyarrow_schema.set(2, new_field) |
| 329 | + assert pyarrow_schema.field(2).type == pa.null() |
| 330 | + actual = str(pyarrow_to_schema(pyarrow_schema)) |
| 331 | + expected = """table { |
| 332 | + 1: foo: optional string |
| 333 | + 2: bar: required int |
| 334 | + 3: baz: optional unknown |
| 335 | +}""" |
| 336 | + assert actual == expected |
| 337 | + |
| 338 | + |
316 | 339 | def test_round_schema_conversion_simple(table_schema_simple: Schema) -> None: |
317 | 340 | actual = str(pyarrow_to_schema(schema_to_pyarrow(table_schema_simple))) |
318 | 341 | expected = """table { |
|
0 commit comments