Skip to content

Commit d9a06ad

Browse files
Remove debugging logs and restore proper test assertions
- Removed temporary DEBUG log messages from complex data type tests - Restored proper test assertions for STRUCT, ARRAY, MAP, and complex combinations - Added meaningful validation for struct conversion behavior - Improved logging to be informative but not verbose - All lint checks and type checks now pass Tests now properly validate that: - Values are not None (query succeeded) - String structs convert to dictionaries when possible - Converted values have correct types - Unexpected types are logged but don't fail tests 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 13f00ec commit d9a06ad

1 file changed

Lines changed: 24 additions & 48 deletions

File tree

tests/pyathena/test_cursor.py

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -790,34 +790,28 @@ def test_struct_types(self, cursor):
790790
struct_value = result[0]
791791
_logger.info(f"{description}: {struct_value!r} (type: {type(struct_value).__name__})")
792792

793-
# Debug: Log the actual struct value we received
794-
_logger.warning(
795-
f"DEBUG - {description}: Raw value = {struct_value!r}, "
796-
f"Type = {type(struct_value).__name__}"
797-
)
793+
# Validate struct value and converter behavior
794+
assert struct_value is not None, f"STRUCT value should not be None for {description}"
798795

799-
# Test if our converter can handle it
796+
# Test struct conversion behavior
800797
if isinstance(struct_value, str):
801798
converted = _to_struct(struct_value)
802-
_logger.info(f" -> Converted: {converted!r}")
803-
# For now, just log conversion results without failing tests
799+
_logger.info(f"{description}: Converted {struct_value!r} -> {converted!r}")
800+
# For string structs, conversion should succeed or return None for complex cases
804801
if converted is not None:
805-
_logger.info(" -> Successfully converted to dict")
806-
else:
807-
_logger.warning(f" -> Conversion failed - unable to parse: {struct_value!r}")
808-
elif struct_value is None:
809-
_logger.error(
810-
f" -> ERROR: {description} returned None - query or type mapping issue"
811-
)
802+
assert isinstance(converted, dict), (
803+
f"Converted struct should be dict for {description}"
804+
)
805+
elif isinstance(struct_value, dict):
806+
# Already converted by the cursor converter
807+
_logger.info(f"{description}: Already converted to dict: {struct_value!r}")
812808
else:
813-
_logger.info(
814-
f" -> Non-string struct value: {struct_value!r} "
815-
f"(type: {type(struct_value).__name__})"
809+
# Log unexpected types for debugging but don't fail
810+
_logger.warning(
811+
f"{description}: Unexpected type {type(struct_value).__name__}: "
812+
f"{struct_value!r}"
816813
)
817814

818-
# For now, allow None values while we debug
819-
# TODO: Re-enable strict assertions once we understand Athena's actual behavior
820-
821815
def test_array_types(self, cursor):
822816
"""Test various ARRAY type scenarios."""
823817
test_cases = [
@@ -845,15 +839,9 @@ def test_array_types(self, cursor):
845839
array_value = result[0]
846840
_logger.info(f"{description}: {array_value!r} (type: {type(array_value).__name__})")
847841

848-
# Debug: Log the actual array value we received
849-
_logger.warning(
850-
f"DEBUG - {description}: Raw value = {array_value!r}, "
851-
f"Type = {type(array_value).__name__}"
852-
)
853-
854-
# For now, allow None values while we debug
855-
if array_value is None:
856-
_logger.error(f" -> ERROR: {description} returned None - query or syntax issue")
842+
# Validate array value
843+
assert array_value is not None, f"ARRAY value should not be None for {description}"
844+
_logger.info(f"{description}: Array value type {type(array_value).__name__}")
857845

858846
def test_map_types(self, cursor):
859847
"""Test various MAP type scenarios."""
@@ -901,15 +889,9 @@ def test_map_types(self, cursor):
901889
map_value = result[0]
902890
_logger.info(f"{description}: {map_value!r} (type: {type(map_value).__name__})")
903891

904-
# Debug: Log the actual map value we received
905-
_logger.warning(
906-
f"DEBUG - {description}: Raw value = {map_value!r}, "
907-
f"Type = {type(map_value).__name__}"
908-
)
909-
910-
# For now, allow None values while we debug
911-
if map_value is None:
912-
_logger.error(f" -> ERROR: {description} returned None - query or syntax issue")
892+
# Validate map value
893+
assert map_value is not None, f"MAP value should not be None for {description}"
894+
_logger.info(f"{description}: Map value type {type(map_value).__name__}")
913895

914896
def test_complex_combinations(self, cursor):
915897
"""Test complex combinations of data types."""
@@ -947,12 +929,6 @@ def test_complex_combinations(self, cursor):
947929
complex_value = result[0]
948930
_logger.info(f"{description}: {complex_value!r} (type: {type(complex_value).__name__})")
949931

950-
# Debug: Log the actual complex value we received
951-
_logger.warning(
952-
f"DEBUG - {description}: Raw value = {complex_value!r}, "
953-
f"Type = {type(complex_value).__name__}"
954-
)
955-
956-
# For now, allow None values while we debug
957-
if complex_value is None:
958-
_logger.error(f" -> ERROR: {description} returned None - query or syntax issue")
932+
# Validate complex value
933+
assert complex_value is not None, f"Complex value should not be None for {description}"
934+
_logger.info(f"{description}: Complex value type {type(complex_value).__name__}")

0 commit comments

Comments
 (0)