Skip to content

Bound the caller-thread start test and test the typed JSON conversion with hint-sensitive values #1263

Closed

Description

@laughingman7743

Summary

Part of #1239. Two gaps remain in the top-level tests after #1253 and #1258. A test hangs instead of failing when the behavior it names breaks, and the JSON branches of the typed converter have no test that depends on the hint. Checked at master fb22d08, offline with --noconftest and placeholder settings.

1. TestCursor::test_execute_interrupted_while_starting_without_kill_on_interrupt hangs instead of failing

The test checks that, without kill_on_interrupt, BaseCursor._start_execution() sends the start request on the caller's thread (pyathena/common.py, if not self._kill_on_interrupt: return start()). It patches pyathena.common.threading.Thread with a MagicMock and asserts thread.assert_not_called() after execute().

When that branch is removed, the cursor creates the patched thread, whose target never runs, and _wait_for_start() waits for its future without a bound. The test then blocks instead of failing; timeout 60 pytest ... ended it with exit code 124. docs/testing.md asks to bound every wait so that a regression fails instead of hanging.

Proposed change: patch threading.Thread with side_effect=AssertionError(...), so that creating the helper thread fails the test at once, and drop the assert_not_called() that the side effect replaces.

2. The typed JSON conversion has no hint-sensitive test

TypedValueConverter._convert_typed_array(), _convert_typed_map(), and _convert_typed_struct() (pyathena/parser.py) parse a JSON value and convert each element with its hinted type. Returning the parsed JSON without that conversion, in any of the three, passes tests/pyathena/test_converter.py and tests/pyathena/test_parser.py. Each existing JSON case uses values that json.loads already decodes to the expected types: integers, booleans, strings, nulls, and json elements.

Proposed change: check a JSON value whose hinted element type differs from what JSON decodes, such as a date that JSON leaves as a string, for an array, a map, and a row. The cursor can produce such a value with CAST(... AS JSON) and a type hint, so a live query is preferred; the cases can share one query.

Activity

  1. laughingman7743 commented on Oct 18, 2026

    @laughingman7743
    MemberAuthor

    Correction to section 2: the cursor cannot produce these values. AthenaResultSet applies type hints only to array, map, row, and struct columns (_COMPLEX_TYPES in pyathena/result_set.py), and a CAST(... AS JSON) column is typed json, so its hint is dropped. Athena renders the dates of complex columns without quotes. The hint-sensitive cases are therefore offline, as docs/testing.md allows for cases the service cannot produce; #1264 adds them to tests/pyathena/test_converter.py::test_typed_json_elements.

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

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