summaryrefslogtreecommitdiffstats
path: root/sqlglot/executor/__init__.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 /sqlglot/executor/__init__.py
parentAdding upstream version 17.11.0. (diff)
downloadsqlglot-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 '')
-rw-r--r--sqlglot/executor/__init__.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/sqlglot/executor/__init__.py b/sqlglot/executor/__init__.py
index 017d5bc..304981b 100644
--- a/sqlglot/executor/__init__.py
+++ b/sqlglot/executor/__init__.py
@@ -28,6 +28,11 @@ if t.TYPE_CHECKING:
from sqlglot.schema import Schema
+PYTHON_TYPE_TO_SQLGLOT = {
+ "dict": "MAP",
+}
+
+
def execute(
sql: str | Expression,
schema: t.Optional[t.Dict | Schema] = None,
@@ -50,7 +55,7 @@ def execute(
Returns:
Simple columnar data structure.
"""
- tables_ = ensure_tables(tables)
+ tables_ = ensure_tables(tables, dialect=read)
if not schema:
schema = {}
@@ -61,7 +66,8 @@ def execute(
assert table is not None
for column in table.columns:
- nested_set(schema, [*keys, column], type(table[0][column]).__name__)
+ py_type = type(table[0][column]).__name__
+ nested_set(schema, [*keys, column], PYTHON_TYPE_TO_SQLGLOT.get(py_type) or py_type)
schema = ensure_schema(schema, dialect=read)