Skip to content

Commit ae11ba4

Browse files
fix: Propagate Table properties to Glue (#2097)
<!-- Thanks for opening a pull request! --> <!-- In the case this PR will resolve an issue, please replace ${GITHUB_ISSUE_ID} below with the actual Github issue id. --> <!-- Closes #${GITHUB_ISSUE_ID} --> # Rationale for this change See #2013 Closes #2064 Continuing the trend, but with glue. # Are these changes tested? See test below # Are there any user-facing changes? When a user specifies property update on commit table, those parameters will be passed to the glue client. <!-- In the case of user-facing changes, please add the changelog label. -->
1 parent effb8cb commit ae11ba4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pyiceberg/catalog/glue.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,20 @@
140140

141141

142142
def _construct_parameters(
143-
metadata_location: str, glue_table: Optional["TableTypeDef"] = None, prev_metadata_location: Optional[str] = None
143+
metadata_location: str,
144+
glue_table: Optional["TableTypeDef"] = None,
145+
prev_metadata_location: Optional[str] = None,
146+
metadata_properties: Optional[Properties] = None,
144147
) -> Properties:
145148
new_parameters = glue_table.get("Parameters", {}) if glue_table else {}
146149
new_parameters.update({TABLE_TYPE: ICEBERG.upper(), METADATA_LOCATION: metadata_location})
147150
if prev_metadata_location:
148151
new_parameters[PREVIOUS_METADATA_LOCATION] = prev_metadata_location
152+
153+
if metadata_properties:
154+
for key, value in metadata_properties.items():
155+
new_parameters[key] = str(value)
156+
149157
return new_parameters
150158

151159

@@ -236,7 +244,7 @@ def _construct_table_input(
236244
table_input: "TableInputTypeDef" = {
237245
"Name": table_name,
238246
"TableType": EXTERNAL_TABLE,
239-
"Parameters": _construct_parameters(metadata_location, glue_table, prev_metadata_location),
247+
"Parameters": _construct_parameters(metadata_location, glue_table, prev_metadata_location, properties),
240248
"StorageDescriptor": {
241249
"Columns": _to_columns(metadata),
242250
"Location": metadata.location,

tests/catalog/test_glue.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,8 @@ def test_commit_table_properties(
791791
Name=table_name,
792792
)
793793
assert table_info["Table"]["Description"] == "test_description"
794+
assert table_info["Table"]["Parameters"]["test_a"] == "test_aa"
795+
assert table_info["Table"]["Parameters"]["test_c"] == "test_c"
794796

795797

796798
@mock_aws

0 commit comments

Comments
 (0)