summaryrefslogtreecommitdiffstats
path: root/tests/test_executor.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-14 10:12:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-14 10:12:13 +0000
commitcdffd0b29d5b072639bb02118d6828f4d1b76099 (patch)
tree57ec0b75c40e40a33060b63599bbba6f0af27ae8 /tests/test_executor.py
parentAdding upstream version 17.11.0. (diff)
downloadsqlglot-6e68791db7a256a08b86e35acf69c5ccff399671.tar.xz
sqlglot-6e68791db7a256a08b86e35acf69c5ccff399671.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.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",)])