Skip to content

Unnamed struct parsing uses naive comma split in typed converter #694

@laughingman7743

Description

@laughingman7743

Summary

In TypedValueConverter._convert_typed_struct(), the unnamed struct path splits values using:

values = [v.strip() for v in inner.split(",")]

This naive split does not respect nested structures. If an unnamed struct field contains a nested struct or array with commas (e.g., {Alice, {x=1, y=2}, 30}), the split will incorrectly break the nested value.

The named struct path correctly uses _split_array_items() which respects brace/bracket grouping.

Current impact

Low — Athena's unnamed ROW format (positional fields without = separators) is relatively uncommon in practice, and nested complex types within unnamed structs are even rarer. The named struct and JSON paths handle nesting correctly.

Proposal

Replace inner.split(",") with _split_array_items(inner) in the unnamed struct branch to match the named struct path's behavior.

This is a one-line change:

# Before
values = [v.strip() for v in inner.split(",")]
# After
values = _split_array_items(inner)

Location

pyathena/parser.py, TypedValueConverter._convert_typed_struct(), around the "Unnamed struct" comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions