summaryrefslogtreecommitdiffstats
path: root/sqlglot/executor/__init__.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 /sqlglot/executor/__init__.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 'sqlglot/executor/__init__.py')
-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)