|
49 | 49 | NoSuchTableError, |
50 | 50 | TableAlreadyExistsError, |
51 | 51 | ) |
52 | | -from pyiceberg.io import AWS_ACCESS_KEY_ID, AWS_PROFILE_NAME, AWS_REGION, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN |
| 52 | +from pyiceberg.io import AWS_ACCESS_KEY_ID, AWS_PROFILE_NAME, AWS_REGION, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, FileIO |
53 | 53 | from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec |
54 | 54 | from pyiceberg.schema import Schema, SchemaVisitor, visit |
55 | | -from pyiceberg.serializers import FromInputFile |
| 55 | +from pyiceberg.serializers import FromInputFile, ToOutputFile |
56 | 56 | from pyiceberg.table import ( |
57 | 57 | CommitTableResponse, |
58 | 58 | Table, |
@@ -441,6 +441,10 @@ def _is_s3tables_database(self, database_name: str) -> bool: |
441 | 441 | federated = database.get("FederatedDatabase", {}) |
442 | 442 | return federated.get("ConnectionType", "") == GLUE_CONNECTION_S3_TABLES |
443 | 443 |
|
| 444 | + @staticmethod |
| 445 | + def _write_metadata_no_exist_check(metadata: TableMetadata, io: FileIO, metadata_path: str) -> None: |
| 446 | + ToOutputFile.table_metadata(metadata, io.new_output(metadata_path), overwrite=True) |
| 447 | + |
444 | 448 | def _create_table_s3tables( |
445 | 449 | self, |
446 | 450 | identifier: str | Identifier, |
@@ -499,7 +503,8 @@ def _create_table_s3tables( |
499 | 503 | ) |
500 | 504 |
|
501 | 505 | # Write metadata and update the Glue table with the metadata pointer. |
502 | | - self._write_metadata(staged_table.metadata, staged_table.io, staged_table.metadata_location) |
| 506 | + # Skip the exist check before writing; S3 Tables doesn't support ListObjectsV2. |
| 507 | + self._write_metadata_no_exist_check(staged_table.metadata, staged_table.io, staged_table.metadata_location) |
503 | 508 | table_input = _construct_table_input(table_name, staged_table.metadata_location, properties, staged_table.metadata) |
504 | 509 | version_id = glue_table.get("VersionId") |
505 | 510 | if not version_id: |
|
0 commit comments