Skip to content

Commit d3644b5

Browse files
committed
fix(glue): Skip file existence check when writing S3 Tables metadata
S3 Tables managed storage does not support ListObjectsV2, which the default _write_metadata path uses to check for file existence before writing. Use overwrite=True to skip the check.
1 parent 420da60 commit d3644b5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pyiceberg/catalog/glue.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
NoSuchTableError,
5050
TableAlreadyExistsError,
5151
)
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
5353
from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec
5454
from pyiceberg.schema import Schema, SchemaVisitor, visit
55-
from pyiceberg.serializers import FromInputFile
55+
from pyiceberg.serializers import FromInputFile, ToOutputFile
5656
from pyiceberg.table import (
5757
CommitTableResponse,
5858
Table,
@@ -441,6 +441,10 @@ def _is_s3tables_database(self, database_name: str) -> bool:
441441
federated = database.get("FederatedDatabase", {})
442442
return federated.get("ConnectionType", "") == GLUE_CONNECTION_S3_TABLES
443443

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+
444448
def _create_table_s3tables(
445449
self,
446450
identifier: str | Identifier,
@@ -499,7 +503,8 @@ def _create_table_s3tables(
499503
)
500504

501505
# 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)
503508
table_input = _construct_table_input(table_name, staged_table.metadata_location, properties, staged_table.metadata)
504509
version_id = glue_table.get("VersionId")
505510
if not version_id:

0 commit comments

Comments
 (0)