Skip to content

Commit 3026b6f

Browse files
committed
general complex types test
1 parent b032c3f commit 3026b6f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tests/e2e/test_complex_types.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from numpy import ndarray
3+
from typing import Sequence
34

45
from tests.e2e.test_driver import PySQLPytestTestCase
56

@@ -17,7 +18,10 @@ def table_fixture(self, connection_details):
1718
CREATE TABLE IF NOT EXISTS pysql_test_complex_types_table (
1819
array_col ARRAY<STRING>,
1920
map_col MAP<STRING, INTEGER>,
20-
struct_col STRUCT<field1: STRING, field2: INTEGER>
21+
struct_col STRUCT<field1: STRING, field2: INTEGER>,
22+
array_array_col ARRAY<ARRAY<STRING>>,
23+
array_map_col ARRAY<MAP<STRING, INTEGER>>,
24+
map_array_col MAP<STRING, ARRAY<STRING>>
2125
)
2226
"""
2327
)
@@ -28,7 +32,10 @@ def table_fixture(self, connection_details):
2832
VALUES (
2933
ARRAY('a', 'b', 'c'),
3034
MAP('a', 1, 'b', 2, 'c', 3),
31-
NAMED_STRUCT('field1', 'a', 'field2', 1)
35+
NAMED_STRUCT('field1', 'a', 'field2', 1),
36+
ARRAY(ARRAY('a','b','c')),
37+
ARRAY(MAP('a', 1, 'b', 2, 'c', 3)),
38+
MAP('a', ARRAY('a', 'b', 'c'), 'b', ARRAY('d', 'e'))
3239
)
3340
"""
3441
)
@@ -38,7 +45,7 @@ def table_fixture(self, connection_details):
3845

3946
@pytest.mark.parametrize(
4047
"field,expected_type",
41-
[("array_col", ndarray), ("map_col", list), ("struct_col", dict)],
48+
[("array_col", ndarray), ("map_col", list), ("struct_col", dict), ("array_array_col", ndarray), ("array_map_col", ndarray), ("map_array_col", list)],
4249
)
4350
def test_read_complex_types_as_arrow(self, field, expected_type, table_fixture):
4451
"""Confirms the return types of a complex type field when reading as arrow"""
@@ -47,10 +54,10 @@ def test_read_complex_types_as_arrow(self, field, expected_type, table_fixture):
4754
result = cursor.execute(
4855
"SELECT * FROM pysql_test_complex_types_table LIMIT 1"
4956
).fetchone()
50-
57+
5158
assert isinstance(result[field], expected_type)
5259

53-
@pytest.mark.parametrize("field", [("array_col"), ("map_col"), ("struct_col")])
60+
@pytest.mark.parametrize("field", [("array_col"), ("map_col"), ("struct_col"), ("array_array_col"), ("array_map_col"), ("map_array_col")])
5461
def test_read_complex_types_as_string(self, field, table_fixture):
5562
"""Confirms the return type of a complex type that is returned as a string"""
5663
with self.cursor(

0 commit comments

Comments
 (0)