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.
Files changed (68) hide show
  1. sqlglot/__init__.py +1 -0
  2. sqlglot/__main__.py +6 -4
  3. sqlglot/_version.py +2 -2
  4. sqlglot/dialects/bigquery.py +118 -279
  5. sqlglot/dialects/clickhouse.py +73 -5
  6. sqlglot/dialects/databricks.py +38 -1
  7. sqlglot/dialects/dialect.py +354 -275
  8. sqlglot/dialects/dremio.py +4 -1
  9. sqlglot/dialects/duckdb.py +754 -25
  10. sqlglot/dialects/exasol.py +243 -10
  11. sqlglot/dialects/hive.py +8 -8
  12. sqlglot/dialects/mysql.py +14 -4
  13. sqlglot/dialects/oracle.py +29 -0
  14. sqlglot/dialects/postgres.py +60 -26
  15. sqlglot/dialects/presto.py +47 -16
  16. sqlglot/dialects/redshift.py +16 -0
  17. sqlglot/dialects/risingwave.py +3 -0
  18. sqlglot/dialects/singlestore.py +12 -3
  19. sqlglot/dialects/snowflake.py +239 -218
  20. sqlglot/dialects/spark.py +15 -4
  21. sqlglot/dialects/spark2.py +11 -48
  22. sqlglot/dialects/sqlite.py +10 -0
  23. sqlglot/dialects/starrocks.py +3 -0
  24. sqlglot/dialects/teradata.py +5 -8
  25. sqlglot/dialects/trino.py +6 -0
  26. sqlglot/dialects/tsql.py +61 -22
  27. sqlglot/diff.py +4 -2
  28. sqlglot/errors.py +69 -0
  29. sqlglot/executor/__init__.py +5 -10
  30. sqlglot/executor/python.py +1 -29
  31. sqlglot/expressions.py +637 -100
  32. sqlglot/generator.py +160 -43
  33. sqlglot/helper.py +2 -44
  34. sqlglot/lineage.py +10 -4
  35. sqlglot/optimizer/annotate_types.py +247 -140
  36. sqlglot/optimizer/canonicalize.py +6 -1
  37. sqlglot/optimizer/eliminate_joins.py +1 -1
  38. sqlglot/optimizer/eliminate_subqueries.py +2 -2
  39. sqlglot/optimizer/merge_subqueries.py +5 -5
  40. sqlglot/optimizer/normalize.py +20 -13
  41. sqlglot/optimizer/normalize_identifiers.py +17 -3
  42. sqlglot/optimizer/optimizer.py +4 -0
  43. sqlglot/optimizer/pushdown_predicates.py +1 -1
  44. sqlglot/optimizer/qualify.py +18 -10
  45. sqlglot/optimizer/qualify_columns.py +122 -275
  46. sqlglot/optimizer/qualify_tables.py +128 -76
  47. sqlglot/optimizer/resolver.py +374 -0
  48. sqlglot/optimizer/scope.py +27 -16
  49. sqlglot/optimizer/simplify.py +1075 -959
  50. sqlglot/optimizer/unnest_subqueries.py +12 -2
  51. sqlglot/parser.py +296 -170
  52. sqlglot/planner.py +2 -2
  53. sqlglot/schema.py +15 -4
  54. sqlglot/tokens.py +42 -7
  55. sqlglot/transforms.py +77 -22
  56. sqlglot/typing/__init__.py +316 -0
  57. sqlglot/typing/bigquery.py +376 -0
  58. sqlglot/typing/hive.py +12 -0
  59. sqlglot/typing/presto.py +24 -0
  60. sqlglot/typing/snowflake.py +505 -0
  61. sqlglot/typing/spark2.py +58 -0
  62. sqlglot/typing/tsql.py +9 -0
  63. {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/METADATA +2 -2
  64. sqlglot-28.4.0.dist-info/RECORD +92 -0
  65. sqlglot-27.27.0.dist-info/RECORD +0 -84
  66. {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/WHEEL +0 -0
  67. {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/licenses/LICENSE +0 -0
  68. {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/top_level.txt +0 -0
@@ -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 csv_reader, subclasses
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