sqlglot 27.27.0__py3-none-any.whl → 28.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlglot/__init__.py +1 -0
- sqlglot/__main__.py +6 -4
- sqlglot/_version.py +2 -2
- sqlglot/dialects/bigquery.py +118 -279
- sqlglot/dialects/clickhouse.py +73 -5
- sqlglot/dialects/databricks.py +38 -1
- sqlglot/dialects/dialect.py +354 -275
- sqlglot/dialects/dremio.py +4 -1
- sqlglot/dialects/duckdb.py +754 -25
- sqlglot/dialects/exasol.py +243 -10
- sqlglot/dialects/hive.py +8 -8
- sqlglot/dialects/mysql.py +14 -4
- sqlglot/dialects/oracle.py +29 -0
- sqlglot/dialects/postgres.py +60 -26
- sqlglot/dialects/presto.py +47 -16
- sqlglot/dialects/redshift.py +16 -0
- sqlglot/dialects/risingwave.py +3 -0
- sqlglot/dialects/singlestore.py +12 -3
- sqlglot/dialects/snowflake.py +239 -218
- sqlglot/dialects/spark.py +15 -4
- sqlglot/dialects/spark2.py +11 -48
- sqlglot/dialects/sqlite.py +10 -0
- sqlglot/dialects/starrocks.py +3 -0
- sqlglot/dialects/teradata.py +5 -8
- sqlglot/dialects/trino.py +6 -0
- sqlglot/dialects/tsql.py +61 -22
- sqlglot/diff.py +4 -2
- sqlglot/errors.py +69 -0
- sqlglot/executor/__init__.py +5 -10
- sqlglot/executor/python.py +1 -29
- sqlglot/expressions.py +637 -100
- sqlglot/generator.py +160 -43
- sqlglot/helper.py +2 -44
- sqlglot/lineage.py +10 -4
- sqlglot/optimizer/annotate_types.py +247 -140
- sqlglot/optimizer/canonicalize.py +6 -1
- sqlglot/optimizer/eliminate_joins.py +1 -1
- sqlglot/optimizer/eliminate_subqueries.py +2 -2
- sqlglot/optimizer/merge_subqueries.py +5 -5
- sqlglot/optimizer/normalize.py +20 -13
- sqlglot/optimizer/normalize_identifiers.py +17 -3
- sqlglot/optimizer/optimizer.py +4 -0
- sqlglot/optimizer/pushdown_predicates.py +1 -1
- sqlglot/optimizer/qualify.py +18 -10
- sqlglot/optimizer/qualify_columns.py +122 -275
- sqlglot/optimizer/qualify_tables.py +128 -76
- sqlglot/optimizer/resolver.py +374 -0
- sqlglot/optimizer/scope.py +27 -16
- sqlglot/optimizer/simplify.py +1075 -959
- sqlglot/optimizer/unnest_subqueries.py +12 -2
- sqlglot/parser.py +296 -170
- sqlglot/planner.py +2 -2
- sqlglot/schema.py +15 -4
- sqlglot/tokens.py +42 -7
- sqlglot/transforms.py +77 -22
- sqlglot/typing/__init__.py +316 -0
- sqlglot/typing/bigquery.py +376 -0
- sqlglot/typing/hive.py +12 -0
- sqlglot/typing/presto.py +24 -0
- sqlglot/typing/snowflake.py +505 -0
- sqlglot/typing/spark2.py +58 -0
- sqlglot/typing/tsql.py +9 -0
- {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/METADATA +2 -2
- sqlglot-28.4.0.dist-info/RECORD +92 -0
- sqlglot-27.27.0.dist-info/RECORD +0 -84
- {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/WHEEL +0 -0
- {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/licenses/LICENSE +0 -0
- {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/top_level.txt +0 -0
sqlglot/executor/python.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import ast
|
|
2
1
|
import collections
|
|
3
2
|
import itertools
|
|
4
3
|
import math
|
|
@@ -9,7 +8,7 @@ from sqlglot.errors import ExecuteError
|
|
|
9
8
|
from sqlglot.executor.context import Context
|
|
10
9
|
from sqlglot.executor.env import ENV
|
|
11
10
|
from sqlglot.executor.table import RowReader, Table
|
|
12
|
-
from sqlglot.helper import
|
|
11
|
+
from sqlglot.helper import subclasses
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
class PythonExecutor:
|
|
@@ -97,9 +96,6 @@ class PythonExecutor:
|
|
|
97
96
|
if not step.projections and not step.condition:
|
|
98
97
|
return self.context({step.name: context.tables[source]})
|
|
99
98
|
table_iter = context.table_iter(source)
|
|
100
|
-
elif isinstance(step.source, exp.Table) and isinstance(step.source.this, exp.ReadCSV):
|
|
101
|
-
table_iter = self.scan_csv(step)
|
|
102
|
-
context = next(table_iter)
|
|
103
99
|
else:
|
|
104
100
|
context, table_iter = self.scan_table(step)
|
|
105
101
|
|
|
@@ -132,30 +128,6 @@ class PythonExecutor:
|
|
|
132
128
|
context = self.context({step.source.alias_or_name: table})
|
|
133
129
|
return context, iter(table)
|
|
134
130
|
|
|
135
|
-
def scan_csv(self, step):
|
|
136
|
-
alias = step.source.alias
|
|
137
|
-
source = step.source.this
|
|
138
|
-
|
|
139
|
-
with csv_reader(source) as reader:
|
|
140
|
-
columns = next(reader)
|
|
141
|
-
table = Table(columns)
|
|
142
|
-
context = self.context({alias: table})
|
|
143
|
-
yield context
|
|
144
|
-
types = []
|
|
145
|
-
for row in reader:
|
|
146
|
-
if not types:
|
|
147
|
-
for v in row:
|
|
148
|
-
try:
|
|
149
|
-
types.append(type(ast.literal_eval(v)))
|
|
150
|
-
except (ValueError, SyntaxError):
|
|
151
|
-
types.append(str)
|
|
152
|
-
|
|
153
|
-
# We can't cast empty values ('') to non-string types, so we convert them to None instead
|
|
154
|
-
context.set_row(
|
|
155
|
-
tuple(None if (t is not str and v == "") else t(v) for t, v in zip(types, row))
|
|
156
|
-
)
|
|
157
|
-
yield context.table.reader
|
|
158
|
-
|
|
159
131
|
def join(self, step, context):
|
|
160
132
|
source = step.source_name
|
|
161
133
|
|