Skip to content

fix: omit Comment key when column_comment is None in add_column - #3435

Open
hsusul wants to merge 1 commit into
aws:mainfrom
hsusul:fix/catalog-add-column-comment-none
Open

fix: omit Comment key when column_comment is None in add_column#3435
hsusul wants to merge 1 commit into
aws:mainfrom
hsusul:fix/catalog-add-column-comment-none

Conversation

@hsusul

@hsusul hsusul commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes a ParamValidationError in awswrangler.catalog.add_column() when calling the function without providing a column_comment (leaving it as default column_comment=None).

Root Cause

When column_comment is None, add_column() appends {"Name": column_name, "Type": column_type, "Comment": column_comment} into table_input["StorageDescriptor"]["Columns"].
During the subsequent client_glue.update_table call, botocore validates TableInput against the AWS Glue service model. Because "Comment": None is explicitly set, botocore parameter 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 when column_comment is not None.

Regression Tests & Validation

  • Added test_glue_add_column_without_comment in tests/unit/test_moto.py testing add_column both with default column_comment=None and with an explicit comment string.
  • Ran AWS_DEFAULT_REGION=us-east-1 uv run pytest tests/unit/test_moto.py (47 passed).
  • Ran uv run ruff check awswrangler/catalog/_add.py tests/unit/test_moto.py.
  • Ran uv run mypy awswrangler/catalog/_add.py.
  • Verified git diff --check.
  • Live AWS integration tests were omitted as local moto unit tests provide full, deterministic verification without requiring live AWS credentials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant