Skip to content

Commit 3a28a0a

Browse files
Fix MAP vs STRUCT type test categorization
- Move numeric key test from STRUCT to MAP (correct type) - Update SQLAlchemy reflection test expectations for MAP conversion - Add proper STRUCT test with named fields - Ensure tests match the actual data type semantics {1=2, 3=4} is MAP format, not STRUCT format. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ef67652 commit 3a28a0a

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

tests/pyathena/sqlalchemy/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def test_reflect_select(self, engine):
255255
date(2017, 1, 2),
256256
b"123",
257257
"[1, 2]",
258-
"{1=2, 3=4}", # map type remains as string
258+
{"1": 2, "3": 4}, # map type now converted to dict
259259
{"a": 1, "b": 2}, # row type now converted to dict
260260
Decimal("0.1"),
261261
]

tests/pyathena/test_converter.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,24 @@ def test_to_struct_athena_complex_cases():
101101
)
102102

103103

104-
def test_to_struct_athena_numeric_keys():
105-
"""Test Athena struct with numeric keys (like maps)"""
106-
struct_value = "{1=2, 3=4}"
107-
result = _to_struct(struct_value)
104+
def test_to_map_athena_numeric_keys():
105+
"""Test Athena map with numeric keys"""
106+
from pyathena.converter import _to_map
107+
108+
map_value = "{1=2, 3=4}"
109+
result = _to_map(map_value)
108110
expected = {"1": 2, "3": 4}
109111
assert result == expected
110112

111113

114+
def test_to_struct_named_fields():
115+
"""Test Athena struct with named fields"""
116+
struct_value = "{name=John, age=30}"
117+
result = _to_struct(struct_value)
118+
expected = {"name": "John", "age": 30}
119+
assert result == expected
120+
121+
112122
def test_to_struct_empty_string():
113123
result = _to_struct("")
114124
assert result is None

0 commit comments

Comments
 (0)