fix: omit Comment key when column_comment is None in add_column - #3435
Open
hsusul wants to merge 1 commit into
Open
fix: omit Comment key when column_comment is None in add_column#3435hsusul wants to merge 1 commit into
hsusul wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a
ParamValidationErrorinawswrangler.catalog.add_column()when calling the function without providing acolumn_comment(leaving it as defaultcolumn_comment=None).Root Cause
When
column_commentisNone,add_column()appends{"Name": column_name, "Type": column_type, "Comment": column_comment}intotable_input["StorageDescriptor"]["Columns"].During the subsequent
client_glue.update_tablecall,botocorevalidatesTableInputagainst the AWS Glue service model. Because"Comment": Noneis explicitly set,botocoreparameter validation fails:botocore.exceptions.ParamValidationError: Parameter validation failed: Invalid type for parameter TableInput.StorageDescriptor.Columns[X].Comment, value: None, type: <class 'NoneType'>, valid types: <class 'str'>Fix
Construct the column dictionary dynamically so that the
"Comment"key is only included whencolumn_commentis notNone.Regression Tests & Validation
test_glue_add_column_without_commentintests/unit/test_moto.pytestingadd_columnboth with defaultcolumn_comment=Noneand with an explicit comment string.AWS_DEFAULT_REGION=us-east-1 uv run pytest tests/unit/test_moto.py(47 passed).uv run ruff check awswrangler/catalog/_add.py tests/unit/test_moto.py.uv run mypy awswrangler/catalog/_add.py.git diff --check.motounit tests provide full, deterministic verification without requiring live AWS credentials.