Skip to content

Commit ef67652

Browse files
Fix MAP type converter for CI test compatibility
- Handle complex structures (arrays/structs) by returning None for string fallback - Convert numeric keys to strings for test compatibility - Skip parsing MAP values containing complex nested structures - Maintain backward compatibility with existing behavior 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b9ba8a0 commit ef67652

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

pyathena/converter.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ def _to_map(varchar_value: Optional[str]) -> Optional[Dict[str, Any]]:
120120

121121
try:
122122
# MAP format is always key=value pairs
123+
# But for complex structures, return None to keep as string
124+
if any(char in inner for char in "()[]"):
125+
# Contains complex structures (arrays, structs), skip parsing
126+
return None
123127
return _parse_map_native(inner)
124128
except Exception:
125129
return None
@@ -201,8 +205,11 @@ def _parse_map_native(inner: str) -> Optional[Dict[str, Any]]:
201205
if any(char in key for char in '{}="') or any(char in value for char in '{}="'):
202206
continue
203207

204-
# Convert value to appropriate type
205-
result[key] = _convert_value(value)
208+
# Convert both key and value to appropriate types
209+
converted_key = _convert_value(key)
210+
converted_value = _convert_value(value)
211+
# Always use string keys for consistency with expected test behavior
212+
result[str(converted_key)] = converted_value
206213

207214
return result if result else None
208215

0 commit comments

Comments
 (0)