Skip to content

Commit 2d3418d

Browse files
committed
Add test query on python dict
1 parent 25faa6b commit 2d3418d

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

tests/test_query_py.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,33 @@ def test_query_arrow2(self):
8888
# )
8989
# self.assertEqual(str(ret), EXPECTED)
9090

91-
# def test_query_dict(self):
92-
# data = {
93-
# "a": [1, 2, 3, 4, 5, 6],
94-
# "b": ["tom", "jerry", "auxten", "tom", "jerry", "auxten"],
95-
# }
91+
def test_query_dict(self):
92+
data = {
93+
"a": [1, 2, 3, 4, 5, 6],
94+
"b": ["tom", "jerry", "auxten", "tom", "jerry", "auxten"],
95+
}
9696

97-
# ret = chdb.query("SELECT b, sum(a) FROM Python(data) GROUP BY b ORDER BY b")
98-
# self.assertEqual(str(ret), EXPECTED)
97+
ret = chdb.query(
98+
"SELECT b, sum(a) FROM Python(data) GROUP BY b ORDER BY b", "debug"
99+
)
100+
self.assertEqual(str(ret), EXPECTED)
101+
102+
def test_query_dict_int(self):
103+
data = {
104+
"a": [1, 2, 3, 4, 5, 6],
105+
"b": [1, 2, 3, 1, 2, 3],
106+
}
107+
108+
ret = chdb.query(
109+
"SELECT b, sum(a) FROM Python(data) GROUP BY b ORDER BY b", "debug"
110+
)
111+
self.assertEqual(
112+
str(ret),
113+
"""1,5
114+
2,7
115+
3,9
116+
""",
117+
)
99118

100119

101120
if __name__ == "__main__":

0 commit comments

Comments
 (0)