diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-14 10:12:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-14 10:12:13 +0000 |
commit | cdffd0b29d5b072639bb02118d6828f4d1b76099 (patch) | |
tree | 57ec0b75c40e40a33060b63599bbba6f0af27ae8 /tests/test_executor.py | |
parent | Adding upstream version 17.11.0. (diff) | |
download | sqlglot-cdffd0b29d5b072639bb02118d6828f4d1b76099.tar.xz sqlglot-cdffd0b29d5b072639bb02118d6828f4d1b76099.zip |
Adding upstream version 17.12.0.upstream/17.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_executor.py')
-rw-r--r-- | tests/test_executor.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_executor.py b/tests/test_executor.py index 9dacbbf..ffe0229 100644 --- a/tests/test_executor.py +++ b/tests/test_executor.py @@ -723,3 +723,24 @@ class TestExecutor(unittest.TestCase): result = execute(sql, tables=tables) self.assertEqual(result.columns, columns) 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) + + self.assertEqual(result.columns, ("NAME",)) + self.assertEqual(result.rows, [("Hello, World",)]) + + tables = { + '"ITEM"': [ + {"id": 1, "attributes": {"flavor": "cherry", "taste": "sweet"}}, + {"id": 2, "attributes": {"flavor": "lime", "taste": "sour"}}, + {"id": 3, "attributes": {"flavor": "apple", "taste": None}}, + ] + } + result = execute("SELECT i.attributes.flavor FROM `ITEM` i", read="bigquery", tables=tables) + + self.assertEqual(result.columns, ("flavor",)) + self.assertEqual(result.rows, [("cherry",), ("lime",), ("apple",)]) |