summaryrefslogtreecommitdiffstats
path: root/tests/test_executor.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_executor.py')
-rw-r--r--tests/test_executor.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/tests/test_executor.py b/tests/test_executor.py
index 78d037a..35935b9 100644
--- a/tests/test_executor.py
+++ b/tests/test_executor.py
@@ -94,11 +94,10 @@ class TestExecutor(unittest.TestCase):
with self.subTest(f"tpch-h {i + 1}"):
sql, _ = self.sqls[i]
a = self.cached_execute(sql)
- b = pd.DataFrame(table.rows, columns=table.columns)
-
- # The executor represents NULL values as None, whereas DuckDB represents them as NaN,
- # and so the following is done to silence Pandas' "Mismatched null-like values" warnings
- b = b.fillna(value=np.nan)
+ b = pd.DataFrame(
+ ((np.nan if c is None else c for c in r) for r in table.rows),
+ columns=table.columns,
+ )
assert_frame_equal(a, b, check_dtype=False, check_index_type=False)
@@ -778,14 +777,24 @@ class TestExecutor(unittest.TestCase):
self.assertEqual(result.rows, expected)
def test_dict_values(self):
- tables = {
- "foo": [{"raw": {"name": "Hello, World"}}],
- }
- result = execute("SELECT raw:name AS name FROM foo", read="snowflake", tables=tables)
+ tables = {"foo": [{"raw": {"name": "Hello, World", "a": [{"b": 1}]}}]}
+ result = execute("SELECT raw:name AS name FROM foo", read="snowflake", tables=tables)
self.assertEqual(result.columns, ("NAME",))
self.assertEqual(result.rows, [("Hello, World",)])
+ result = execute("SELECT raw:a[0].b AS b FROM foo", read="snowflake", tables=tables)
+ self.assertEqual(result.columns, ("B",))
+ self.assertEqual(result.rows, [(1,)])
+
+ result = execute("SELECT raw:a[1].b AS b FROM foo", read="snowflake", tables=tables)
+ self.assertEqual(result.columns, ("B",))
+ self.assertEqual(result.rows, [(None,)])
+
+ result = execute("SELECT raw:a[0].c AS c FROM foo", read="snowflake", tables=tables)
+ self.assertEqual(result.columns, ("C",))
+ self.assertEqual(result.rows, [(None,)])
+
tables = {
'"ITEM"': [
{"id": 1, "attributes": {"flavor": "cherry", "taste": "sweet"}},