Skip to content

TypeSignatureParser assumes closing parenthesis is at end of string #693

@laughingman7743

Description

@laughingman7743

Summary

TypeSignatureParser.parse() extracts the inner content of a parameterized type using:

inner = type_str[paren_idx + 1 : -1].strip()

This assumes the closing ) is always the last character of the string. If a type signature has a modifier after the closing parenthesis — such as timestamp(3) with time zone — the parser would incorrectly truncate the trailing text.

Current impact

Low — Athena's current DDL type system does not produce this pattern in result_set_type_hints contexts. The timestamp with time zone type is returned by Athena metadata as a flat string (no parenthesized parameter), so this does not affect real-world usage today.

Proposal

Either:

  1. Handle trailing modifiers by finding the matching ) instead of assuming it's at [-1]
  2. Document the limitation explicitly in the type hint docs (e.g., "type signatures must not contain trailing modifiers after the closing parenthesis")

Option 2 is probably sufficient unless Athena/Trino introduces new parameterized types with modifiers.

Location

pyathena/parser.py, TypeSignatureParser.parse() method.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions