summaryrefslogtreecommitdiffstats
path: root/tests/test_executor.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-14 10:12:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-14 10:12:19 +0000
commit3742f86d166160ca3843872ebecb6f30c51f6085 (patch)
tree6d747c3e7082fc2bae56053930813d5625e9b3d8 /tests/test_executor.py
parentReleasing debian version 17.11.0-1. (diff)
downloadsqlglot-3742f86d166160ca3843872ebecb6f30c51f6085.tar.xz
sqlglot-3742f86d166160ca3843872ebecb6f30c51f6085.zip
Merging upstream version 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.py21
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",)])