sqlglotc 30.0.3__tar.gz → 30.1.0__tar.gz

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 (108) hide show
  1. {sqlglotc-30.0.3/sqlglotc.egg-info → sqlglotc-30.1.0}/PKG-INFO +1 -1
  2. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/setup.py +2 -0
  3. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/errors.py +3 -3
  4. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/builders.py +18 -13
  5. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/core.py +71 -68
  6. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/ddl.py +4 -0
  7. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/dml.py +9 -9
  8. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/functions.py +2 -2
  9. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/properties.py +4 -0
  10. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/query.py +54 -33
  11. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/string.py +1 -0
  12. sqlglotc-30.1.0/sqlglot/generator.py +5819 -0
  13. sqlglotc-30.1.0/sqlglot/generators/athena.py +180 -0
  14. sqlglotc-30.1.0/sqlglot/generators/bigquery.py +686 -0
  15. sqlglotc-30.1.0/sqlglot/generators/clickhouse.py +665 -0
  16. sqlglotc-30.1.0/sqlglot/generators/databricks.py +101 -0
  17. sqlglotc-30.1.0/sqlglot/generators/doris.py +612 -0
  18. sqlglotc-30.1.0/sqlglot/generators/dremio.py +100 -0
  19. sqlglotc-30.1.0/sqlglot/generators/drill.py +112 -0
  20. sqlglotc-30.1.0/sqlglot/generators/druid.py +31 -0
  21. sqlglotc-30.1.0/sqlglot/generators/duckdb.py +4179 -0
  22. sqlglotc-30.1.0/sqlglot/generators/dune.py +14 -0
  23. sqlglotc-30.1.0/sqlglot/generators/exasol.py +926 -0
  24. sqlglotc-30.1.0/sqlglot/generators/fabric.py +149 -0
  25. sqlglotc-30.1.0/sqlglot/generators/hive.py +544 -0
  26. sqlglotc-30.1.0/sqlglot/generators/materialize.py +56 -0
  27. sqlglotc-30.1.0/sqlglot/generators/mysql.py +795 -0
  28. sqlglotc-30.1.0/sqlglot/generators/oracle.py +165 -0
  29. sqlglotc-30.1.0/sqlglot/generators/postgres.py +567 -0
  30. sqlglotc-30.1.0/sqlglot/generators/presto.py +647 -0
  31. sqlglotc-30.1.0/sqlglot/generators/prql.py +7 -0
  32. sqlglotc-30.1.0/sqlglot/generators/redshift.py +347 -0
  33. sqlglotc-30.1.0/sqlglot/generators/risingwave.py +32 -0
  34. sqlglotc-30.1.0/sqlglot/generators/singlestore.py +1595 -0
  35. sqlglotc-30.1.0/sqlglot/generators/snowflake.py +1138 -0
  36. sqlglotc-30.1.0/sqlglot/generators/solr.py +7 -0
  37. sqlglotc-30.1.0/sqlglot/generators/spark.py +202 -0
  38. sqlglotc-30.1.0/sqlglot/generators/spark2.py +253 -0
  39. sqlglotc-30.1.0/sqlglot/generators/sqlite.py +320 -0
  40. sqlglotc-30.1.0/sqlglot/generators/starrocks.py +325 -0
  41. sqlglotc-30.1.0/sqlglot/generators/tableau.py +51 -0
  42. sqlglotc-30.1.0/sqlglot/generators/teradata.py +181 -0
  43. sqlglotc-30.1.0/sqlglot/generators/trino.py +68 -0
  44. sqlglotc-30.1.0/sqlglot/generators/tsql.py +624 -0
  45. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/helper.py +18 -17
  46. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/optimizer/qualify_columns.py +7 -6
  47. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/optimizer/resolver.py +11 -12
  48. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/optimizer/scope.py +24 -21
  49. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parser.py +85 -90
  50. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/clickhouse.py +11 -8
  51. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/dremio.py +2 -2
  52. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/duckdb.py +5 -3
  53. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/hive.py +1 -1
  54. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/prql.py +2 -1
  55. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/redshift.py +5 -3
  56. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/snowflake.py +33 -17
  57. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/tsql.py +2 -1
  58. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/schema.py +9 -8
  59. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/trie.py +3 -2
  60. {sqlglotc-30.0.3 → sqlglotc-30.1.0/sqlglotc.egg-info}/PKG-INFO +1 -1
  61. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglotc.egg-info/SOURCES.txt +33 -0
  62. sqlglotc-30.1.0/sqlglotc.egg-info/top_level.txt +2 -0
  63. sqlglotc-30.0.3/sqlglotc.egg-info/top_level.txt +0 -2
  64. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/MANIFEST.in +0 -0
  65. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/pyproject.toml +0 -0
  66. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/setup.cfg +0 -0
  67. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/executor/table.py +0 -0
  68. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/aggregate.py +0 -0
  69. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/array.py +0 -0
  70. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/constraints.py +0 -0
  71. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/datatypes.py +0 -0
  72. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/json.py +0 -0
  73. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/math.py +0 -0
  74. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/expressions/temporal.py +0 -0
  75. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/optimizer/isolate_table_selects.py +0 -0
  76. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/optimizer/normalize_identifiers.py +0 -0
  77. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/optimizer/qualify.py +0 -0
  78. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/optimizer/qualify_tables.py +0 -0
  79. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/athena.py +0 -0
  80. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/base.py +0 -0
  81. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/bigquery.py +0 -0
  82. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/databricks.py +0 -0
  83. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/doris.py +0 -0
  84. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/drill.py +0 -0
  85. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/druid.py +0 -0
  86. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/dune.py +0 -0
  87. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/exasol.py +0 -0
  88. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/fabric.py +0 -0
  89. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/materialize.py +0 -0
  90. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/mysql.py +0 -0
  91. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/oracle.py +0 -0
  92. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/postgres.py +0 -0
  93. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/presto.py +0 -0
  94. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/risingwave.py +0 -0
  95. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/singlestore.py +0 -0
  96. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/solr.py +0 -0
  97. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/spark.py +0 -0
  98. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/spark2.py +0 -0
  99. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/sqlite.py +0 -0
  100. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/starrocks.py +0 -0
  101. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/tableau.py +0 -0
  102. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/teradata.py +0 -0
  103. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/parsers/trino.py +0 -0
  104. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/serde.py +0 -0
  105. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/time.py +0 -0
  106. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglot/tokenizer_core.py +0 -0
  107. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglotc.egg-info/dependency_links.txt +0 -0
  108. {sqlglotc-30.0.3 → sqlglotc-30.1.0}/sqlglotc.egg-info/requires.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlglotc
3
- Version: 30.0.3
3
+ Version: 30.1.0
4
4
  Summary: mypyc-compiled extensions for sqlglot
5
5
  Author-email: Toby Mao <toby.mao@gmail.com>
6
6
  License-Expression: MIT
@@ -44,6 +44,7 @@ def _subpkg_files(src_dir, subpkg, files=None):
44
44
  def _source_files(src_dir):
45
45
  return [
46
46
  "errors.py",
47
+ "generator.py",
47
48
  "helper.py",
48
49
  "parser.py",
49
50
  "schema.py",
@@ -52,6 +53,7 @@ def _source_files(src_dir):
52
53
  "tokenizer_core.py",
53
54
  "trie.py",
54
55
  *_subpkg_files(src_dir, "expressions"),
56
+ *_subpkg_files(src_dir, "generators"),
55
57
  *_subpkg_files(
56
58
  src_dir,
57
59
  "optimizer",
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import typing as t
4
4
  from enum import auto
5
-
5
+ from collections.abc import Sequence
6
6
  from sqlglot.helper import AutoName
7
7
 
8
8
 
@@ -150,7 +150,7 @@ def highlight_sql(
150
150
  return formatted_sql, start_context, highlight, end_context
151
151
 
152
152
 
153
- def concat_messages(errors: t.Sequence[t.Any], maximum: int) -> str:
153
+ def concat_messages(errors: Sequence[t.Any], maximum: int) -> str:
154
154
  msg = [str(e) for e in errors[:maximum]]
155
155
  remaining = len(errors) - maximum
156
156
  if remaining > 0:
@@ -158,5 +158,5 @@ def concat_messages(errors: t.Sequence[t.Any], maximum: int) -> str:
158
158
  return "\n\n".join(msg)
159
159
 
160
160
 
161
- def merge_errors(errors: t.Sequence[ParseError]) -> t.List[t.Dict[str, t.Any]]:
161
+ def merge_errors(errors: Sequence[ParseError]) -> list[dict[str, t.Any]]:
162
162
  return [e_dict for error in errors for e_dict in error.errors]
@@ -50,13 +50,14 @@ from sqlglot.expressions.functions import Case, Cast
50
50
  from sqlglot.expressions.array import Array
51
51
 
52
52
  if t.TYPE_CHECKING:
53
+ from collections.abc import Sequence, Iterable
53
54
  from sqlglot.dialects.dialect import DialectType
54
55
  from sqlglot.expressions.core import ExpOrStr, Func
55
56
  from sqlglot.expressions.datatypes import DATA_TYPE
56
57
  from sqlglot.expressions.query import Query
57
58
 
58
59
 
59
- def select(*expressions: ExpOrStr, dialect: DialectType = None, **opts) -> Select:
60
+ def select(*expressions: ExpOrStr, dialect: DialectType = None, **opts: t.Any) -> Select:
60
61
  """
61
62
  Initializes a syntax tree from one or multiple SELECT expressions.
62
63
 
@@ -78,7 +79,7 @@ def select(*expressions: ExpOrStr, dialect: DialectType = None, **opts) -> Selec
78
79
  return Select().select(*expressions, dialect=dialect, **opts)
79
80
 
80
81
 
81
- def from_(expression: ExpOrStr, dialect: DialectType = None, **opts) -> Select:
82
+ def from_(expression: ExpOrStr, dialect: DialectType = None, **opts: t.Any) -> Select:
82
83
  """
83
84
  Initializes a syntax tree from a FROM expression.
84
85
 
@@ -105,9 +106,9 @@ def update(
105
106
  properties: t.Optional[dict] = None,
106
107
  where: t.Optional[ExpOrStr] = None,
107
108
  from_: t.Optional[ExpOrStr] = None,
108
- with_: t.Optional[t.Dict[str, ExpOrStr]] = None,
109
+ with_: t.Optional[dict[str, ExpOrStr]] = None,
109
110
  dialect: DialectType = None,
110
- **opts,
111
+ **opts: t.Any,
111
112
  ) -> Update:
112
113
  """
113
114
  Creates an update statement.
@@ -166,7 +167,7 @@ def delete(
166
167
  where: t.Optional[ExpOrStr] = None,
167
168
  returning: t.Optional[ExpOrStr] = None,
168
169
  dialect: DialectType = None,
169
- **opts,
170
+ **opts: t.Any,
170
171
  ) -> Delete:
171
172
  """
172
173
  Builds a delete statement.
@@ -195,12 +196,12 @@ def delete(
195
196
  def insert(
196
197
  expression: ExpOrStr,
197
198
  into: ExpOrStr,
198
- columns: t.Optional[t.Sequence[str | Identifier]] = None,
199
+ columns: t.Optional[Sequence[str | Identifier]] = None,
199
200
  overwrite: t.Optional[bool] = None,
200
201
  returning: t.Optional[ExpOrStr] = None,
201
202
  dialect: DialectType = None,
202
203
  copy: bool = True,
203
- **opts,
204
+ **opts: t.Any,
204
205
  ) -> Insert:
205
206
  """
206
207
  Builds an INSERT statement.
@@ -244,7 +245,7 @@ def merge(
244
245
  returning: t.Optional[ExpOrStr] = None,
245
246
  dialect: DialectType = None,
246
247
  copy: bool = True,
247
- **opts,
248
+ **opts: t.Any,
248
249
  ) -> Merge:
249
250
  """
250
251
  Builds a MERGE statement.
@@ -408,7 +409,7 @@ def subquery(
408
409
  expression: ExpOrStr,
409
410
  alias: t.Optional[Identifier | str] = None,
410
411
  dialect: DialectType = None,
411
- **opts,
412
+ **opts: t.Any,
412
413
  ) -> Select:
413
414
  """
414
415
  Build a subquery expression that's selected from.
@@ -433,7 +434,11 @@ def subquery(
433
434
 
434
435
 
435
436
  def cast(
436
- expression: ExpOrStr, to: DATA_TYPE, copy: bool = True, dialect: DialectType = None, **opts
437
+ expression: ExpOrStr,
438
+ to: DATA_TYPE,
439
+ copy: bool = True,
440
+ dialect: DialectType = None,
441
+ **opts: t.Any,
437
442
  ) -> Cast:
438
443
  """Cast an expression to a data type.
439
444
 
@@ -512,9 +517,9 @@ def table_(
512
517
 
513
518
 
514
519
  def values(
515
- values: t.Iterable[t.Tuple[object, ...] | Tuple],
520
+ values: Iterable[tuple[object, ...] | Tuple],
516
521
  alias: t.Optional[str] = None,
517
- columns: t.Optional[t.Iterable[str] | t.Dict[str, DataType]] = None,
522
+ columns: t.Optional[Iterable[str] | dict[str, DataType]] = None,
518
523
  ) -> Values:
519
524
  """Build VALUES statement.
520
525
 
@@ -962,7 +967,7 @@ def func(name: str, *args, copy: bool = True, dialect: DialectType = None, **kwa
962
967
 
963
968
  def case(
964
969
  expression: t.Optional[ExpOrStr] = None,
965
- **opts,
970
+ **opts: t.Any,
966
971
  ) -> Case:
967
972
  """
968
973
  Initialize a CASE statement.
@@ -14,7 +14,7 @@ from collections import deque
14
14
  from copy import deepcopy
15
15
  from decimal import Decimal
16
16
  from functools import reduce
17
-
17
+ from collections.abc import Iterator, Sequence, Collection
18
18
  from sqlglot._typing import E
19
19
  from sqlglot.errors import ParseError
20
20
  from sqlglot.helper import (
@@ -26,6 +26,7 @@ from sqlglot.helper import (
26
26
  )
27
27
 
28
28
  from sqlglot.tokenizer_core import Token
29
+ from builtins import type as Type
29
30
 
30
31
  if t.TYPE_CHECKING:
31
32
  from sqlglot.dialects.dialect import DialectType
@@ -221,16 +222,16 @@ class Expr:
221
222
  def depth(self) -> int:
222
223
  raise NotImplementedError
223
224
 
224
- def iter_expressions(self: E, reverse: bool = False) -> t.Iterator[E]:
225
+ def iter_expressions(self: E, reverse: bool = False) -> Iterator[E]:
225
226
  raise NotImplementedError
226
227
 
227
- def find(self, *expression_types: t.Type[E], bfs: bool = True) -> t.Optional[E]:
228
+ def find(self, *expression_types: Type[E], bfs: bool = True) -> t.Optional[E]:
228
229
  raise NotImplementedError
229
230
 
230
- def find_all(self, *expression_types: t.Type[E], bfs: bool = True) -> t.Iterator[E]:
231
+ def find_all(self, *expression_types: Type[E], bfs: bool = True) -> Iterator[E]:
231
232
  raise NotImplementedError
232
233
 
233
- def find_ancestor(self, *expression_types: t.Type[E]) -> t.Optional[E]:
234
+ def find_ancestor(self, *expression_types: Type[E]) -> t.Optional[E]:
234
235
  raise NotImplementedError
235
236
 
236
237
  @property
@@ -246,13 +247,13 @@ class Expr:
246
247
 
247
248
  def walk(
248
249
  self, bfs: bool = True, prune: t.Optional[t.Callable[[Expr], bool]] = None
249
- ) -> t.Iterator[Expr]:
250
+ ) -> Iterator[Expr]:
250
251
  raise NotImplementedError
251
252
 
252
- def dfs(self, prune: t.Optional[t.Callable[[Expr], bool]] = None) -> t.Iterator[Expr]:
253
+ def dfs(self, prune: t.Optional[t.Callable[[Expr], bool]] = None) -> Iterator[Expr]:
253
254
  raise NotImplementedError
254
255
 
255
- def bfs(self, prune: t.Optional[t.Callable[[Expr], bool]] = None) -> t.Iterator[Expr]:
256
+ def bfs(self, prune: t.Optional[t.Callable[[Expr], bool]] = None) -> Iterator[Expr]:
256
257
  raise NotImplementedError
257
258
 
258
259
  def unnest(self) -> Expr:
@@ -264,13 +265,13 @@ class Expr:
264
265
  def unnest_operands(self) -> t.Tuple[Expr, ...]:
265
266
  raise NotImplementedError
266
267
 
267
- def flatten(self, unnest: bool = True) -> t.Iterator[Expr]:
268
+ def flatten(self, unnest: bool = True) -> Iterator[Expr]:
268
269
  raise NotImplementedError
269
270
 
270
271
  def to_s(self) -> str:
271
272
  raise NotImplementedError
272
273
 
273
- def sql(self, dialect: DialectType = None, **opts: t.Any) -> str:
274
+ def sql(self, dialect: DialectType = None, **opts: object) -> str:
274
275
  raise NotImplementedError
275
276
 
276
277
  def transform(
@@ -284,10 +285,10 @@ class Expr:
284
285
  def pop(self: E) -> E:
285
286
  raise NotImplementedError
286
287
 
287
- def assert_is(self, type_: t.Type[E]) -> E:
288
+ def assert_is(self, type_: Type[E]) -> E:
288
289
  raise NotImplementedError
289
290
 
290
- def error_messages(self, args: t.Optional[t.Sequence] = None) -> t.List[str]:
291
+ def error_messages(self, args: t.Optional[Sequence[object]] = None) -> list[str]:
291
292
  raise NotImplementedError
292
293
 
293
294
  def dump(self) -> t.Any:
@@ -315,7 +316,7 @@ class Expr:
315
316
  dialect: DialectType = None,
316
317
  copy: bool = True,
317
318
  wrap: bool = True,
318
- **opts: t.Any,
319
+ **opts: object,
319
320
  ) -> Condition:
320
321
  raise NotImplementedError
321
322
 
@@ -325,7 +326,7 @@ class Expr:
325
326
  dialect: DialectType = None,
326
327
  copy: bool = True,
327
328
  wrap: bool = True,
328
- **opts: t.Any,
329
+ **opts: object,
329
330
  ) -> Condition:
330
331
  raise NotImplementedError
331
332
 
@@ -348,26 +349,26 @@ class Expr:
348
349
  quoted: t.Optional[bool] = None,
349
350
  dialect: DialectType = None,
350
351
  copy: bool = True,
351
- **opts: t.Any,
352
+ **opts: object,
352
353
  ) -> Expr:
353
354
  raise NotImplementedError
354
355
 
355
- def _binop(self, klass: t.Type[E], other: t.Any, reverse: bool = False) -> E:
356
+ def _binop(self, klass: Type[E], other: t.Any, reverse: bool = False) -> E:
356
357
  raise NotImplementedError
357
358
 
358
359
  def __getitem__(self, other: ExpOrStr | t.Tuple[ExpOrStr, ...]) -> Bracket:
359
360
  raise NotImplementedError
360
361
 
361
- def __iter__(self) -> t.Iterator:
362
+ def __iter__(self) -> Iterator:
362
363
  raise NotImplementedError
363
364
 
364
365
  def isin(
365
366
  self,
366
367
  *expressions: t.Any,
367
368
  query: t.Optional[ExpOrStr] = None,
368
- unnest: t.Optional[ExpOrStr] | t.Collection[ExpOrStr] = None,
369
+ unnest: t.Optional[ExpOrStr] | Collection[ExpOrStr] = None,
369
370
  copy: bool = True,
370
- **opts,
371
+ **opts: object,
371
372
  ) -> In:
372
373
  raise NotImplementedError
373
374
 
@@ -377,7 +378,7 @@ class Expr:
377
378
  high: t.Any,
378
379
  copy: bool = True,
379
380
  symmetric: t.Optional[bool] = None,
380
- **opts,
381
+ **opts: object,
381
382
  ) -> Between:
382
383
  raise NotImplementedError
383
384
 
@@ -832,7 +833,7 @@ class Expression(Expr):
832
833
  return self.parent.depth + 1
833
834
  return 0
834
835
 
835
- def iter_expressions(self: E, reverse: bool = False) -> t.Iterator[E]:
836
+ def iter_expressions(self: E, reverse: bool = False) -> Iterator[E]:
836
837
  """Yields the key and expression for all arguments, exploding list args."""
837
838
  for vs in reversed(self.args.values()) if reverse else self.args.values():
838
839
  if isinstance(vs, list):
@@ -842,7 +843,7 @@ class Expression(Expr):
842
843
  elif isinstance(vs, Expr):
843
844
  yield t.cast(E, vs)
844
845
 
845
- def find(self, *expression_types: t.Type[E], bfs: bool = True) -> t.Optional[E]:
846
+ def find(self, *expression_types: Type[E], bfs: bool = True) -> t.Optional[E]:
846
847
  """
847
848
  Returns the first node in this tree which matches at least one of
848
849
  the specified types.
@@ -856,7 +857,7 @@ class Expression(Expr):
856
857
  """
857
858
  return next(self.find_all(*expression_types, bfs=bfs), None)
858
859
 
859
- def find_all(self, *expression_types: t.Type[E], bfs: bool = True) -> t.Iterator[E]:
860
+ def find_all(self, *expression_types: Type[E], bfs: bool = True) -> Iterator[E]:
860
861
  """
861
862
  Returns a generator object which visits all nodes in this tree and only
862
863
  yields those that match at least one of the specified expression types.
@@ -872,7 +873,7 @@ class Expression(Expr):
872
873
  if isinstance(expression, expression_types):
873
874
  yield expression
874
875
 
875
- def find_ancestor(self, *expression_types: t.Type[E]) -> t.Optional[E]:
876
+ def find_ancestor(self, *expression_types: Type[E]) -> t.Optional[E]:
876
877
  """
877
878
  Returns a nearest parent matching expression_types.
878
879
 
@@ -912,7 +913,7 @@ class Expression(Expr):
912
913
 
913
914
  def walk(
914
915
  self, bfs: bool = True, prune: t.Optional[t.Callable[[Expr], bool]] = None
915
- ) -> t.Iterator[Expr]:
916
+ ) -> Iterator[Expr]:
916
917
  """
917
918
  Returns a generator object which visits all nodes in this tree.
918
919
 
@@ -930,7 +931,7 @@ class Expression(Expr):
930
931
  else:
931
932
  yield from self.dfs(prune=prune)
932
933
 
933
- def dfs(self, prune: t.Optional[t.Callable[[Expr], bool]] = None) -> t.Iterator[Expr]:
934
+ def dfs(self, prune: t.Optional[t.Callable[[Expr], bool]] = None) -> Iterator[Expr]:
934
935
  """
935
936
  Returns a generator object which visits all nodes in this tree in
936
937
  the DFS (Depth-first) order.
@@ -948,7 +949,7 @@ class Expression(Expr):
948
949
  for v in node.iter_expressions(reverse=True):
949
950
  stack.append(v)
950
951
 
951
- def bfs(self, prune: t.Optional[t.Callable[[Expr], bool]] = None) -> t.Iterator[Expr]:
952
+ def bfs(self, prune: t.Optional[t.Callable[[Expr], bool]] = None) -> Iterator[Expr]:
952
953
  """
953
954
  Returns a generator object which visits all nodes in this tree in
954
955
  the BFS (Breadth-first) order.
@@ -990,7 +991,7 @@ class Expression(Expr):
990
991
  """
991
992
  return tuple(arg.unnest() for arg in self.iter_expressions())
992
993
 
993
- def flatten(self, unnest: bool = True) -> t.Iterator[Expr]:
994
+ def flatten(self, unnest: bool = True) -> Iterator[Expr]:
994
995
  """
995
996
  Returns a generator which yields child nodes whose parents are the same class.
996
997
 
@@ -1115,7 +1116,7 @@ class Expression(Expr):
1115
1116
  self.replace(None)
1116
1117
  return self
1117
1118
 
1118
- def assert_is(self, type_: t.Type[E]) -> E:
1119
+ def assert_is(self, type_: Type[E]) -> E:
1119
1120
  """
1120
1121
  Assert that this `Expr` is an instance of `type_`.
1121
1122
 
@@ -1133,7 +1134,7 @@ class Expression(Expr):
1133
1134
  raise AssertionError(f"{self} is not {type_}.")
1134
1135
  return self
1135
1136
 
1136
- def error_messages(self, args: t.Optional[t.Sequence] = None) -> t.List[str]:
1137
+ def error_messages(self, args: t.Optional[Sequence[object]] = None) -> list[str]:
1137
1138
  """
1138
1139
  Checks if this expression is valid (e.g. all mandatory args are set).
1139
1140
 
@@ -1149,7 +1150,7 @@ class Expression(Expr):
1149
1150
  if k not in self.arg_types:
1150
1151
  raise TypeError(f"Unexpected keyword: '{k}' for {self.__class__}")
1151
1152
 
1152
- errors: t.Optional[t.List[str]] = None
1153
+ errors: t.Optional[list[str]] = None
1153
1154
 
1154
1155
  for k in self.required_args:
1155
1156
  v = self.args.get(k)
@@ -1179,7 +1180,7 @@ class Expression(Expr):
1179
1180
  dialect: DialectType = None,
1180
1181
  copy: bool = True,
1181
1182
  wrap: bool = True,
1182
- **opts: t.Any,
1183
+ **opts: object,
1183
1184
  ) -> Condition:
1184
1185
  """
1185
1186
  AND this condition with one or multiple expressions.
@@ -1209,7 +1210,7 @@ class Expression(Expr):
1209
1210
  dialect: DialectType = None,
1210
1211
  copy: bool = True,
1211
1212
  wrap: bool = True,
1212
- **opts: t.Any,
1213
+ **opts: object,
1213
1214
  ) -> Condition:
1214
1215
  """
1215
1216
  OR this condition with one or multiple expressions.
@@ -1301,7 +1302,7 @@ class Expression(Expr):
1301
1302
  ) -> Expr:
1302
1303
  return alias_(self, alias, quoted=quoted, dialect=dialect, copy=copy, **opts)
1303
1304
 
1304
- def _binop(self, klass: t.Type[E], other: t.Any, reverse: bool = False) -> E:
1305
+ def _binop(self, klass: Type[E], other: t.Any, reverse: bool = False) -> E:
1305
1306
  this = self.copy()
1306
1307
  other = convert(other, copy=True)
1307
1308
  if not isinstance(this, klass) and not isinstance(other, klass):
@@ -1311,12 +1312,12 @@ class Expression(Expr):
1311
1312
  return klass(this=other, expression=this)
1312
1313
  return klass(this=this, expression=other)
1313
1314
 
1314
- def __getitem__(self, other: ExpOrStr | t.Tuple[ExpOrStr, ...]) -> Bracket:
1315
+ def __getitem__(self, other: ExpOrStr | tuple[ExpOrStr, ...]) -> Bracket:
1315
1316
  return Bracket(
1316
1317
  this=self.copy(), expressions=[convert(e, copy=True) for e in ensure_list(other)]
1317
1318
  )
1318
1319
 
1319
- def __iter__(self) -> t.Iterator:
1320
+ def __iter__(self) -> Iterator:
1320
1321
  if "expressions" in self.arg_types:
1321
1322
  return iter(self.args.get("expressions") or [])
1322
1323
  # We define this because __getitem__ converts Expr into an iterable, which is
@@ -1328,9 +1329,9 @@ class Expression(Expr):
1328
1329
  self,
1329
1330
  *expressions: t.Any,
1330
1331
  query: t.Optional[ExpOrStr] = None,
1331
- unnest: t.Optional[ExpOrStr] | t.Collection[ExpOrStr] = None,
1332
+ unnest: t.Optional[ExpOrStr] | Collection[ExpOrStr] = None,
1332
1333
  copy: bool = True,
1333
- **opts,
1334
+ **opts: t.Any,
1334
1335
  ) -> In:
1335
1336
  subquery = maybe_parse(query, copy=copy, **opts) if query else None
1336
1337
  if subquery and not subquery.is_subquery:
@@ -1358,7 +1359,7 @@ class Expression(Expr):
1358
1359
  high: t.Any,
1359
1360
  copy: bool = True,
1360
1361
  symmetric: t.Optional[bool] = None,
1361
- **opts,
1362
+ **opts: object,
1362
1363
  ) -> Between:
1363
1364
  between = Between(
1364
1365
  this=maybe_copy(self, copy),
@@ -1473,10 +1474,7 @@ class Expression(Expr):
1473
1474
  return not_(self.copy())
1474
1475
 
1475
1476
 
1476
- IntoType = t.Union[
1477
- t.Type[Expr],
1478
- t.Collection[t.Type[Expr]],
1479
- ]
1477
+ IntoType = t.Union[Type[Expr], Collection[Type[Expr]]]
1480
1478
  ExpOrStr = t.Union[int, str, Expr]
1481
1479
 
1482
1480
 
@@ -1776,7 +1774,7 @@ class Dot(Expression, Binary):
1776
1774
  return self.name
1777
1775
 
1778
1776
  @classmethod
1779
- def build(self, expressions: t.Sequence[Expr]) -> Dot:
1777
+ def build(self, expressions: Sequence[Expr]) -> Dot:
1780
1778
  """Build a Dot object with a sequence of expressions."""
1781
1779
  if len(expressions) < 2:
1782
1780
  raise ValueError("Dot requires >= 2 expressions.")
@@ -1836,6 +1834,7 @@ class Bracket(Expression, Condition):
1836
1834
  "offset": False,
1837
1835
  "safe": False,
1838
1836
  "returns_list_for_maps": False,
1837
+ "json_access": False,
1839
1838
  }
1840
1839
 
1841
1840
  @property
@@ -1932,7 +1931,7 @@ class TimeUnit(Expr):
1932
1931
  "Y": "YEAR",
1933
1932
  }
1934
1933
 
1935
- VAR_LIKE: t.ClassVar[t.Tuple[t.Type[Expr], ...]] = (Column, Literal, Var)
1934
+ VAR_LIKE: t.ClassVar[t.Tuple[Type[Expr], ...]] = (Column, Literal, Var)
1936
1935
 
1937
1936
  def __init__(self, **args: object) -> None:
1938
1937
  super().__init__(**args)
@@ -2215,7 +2214,9 @@ class RegexpLike(Expression, Binary, Func):
2215
2214
  arg_types = {"this": True, "expression": True, "flag": False, "full_match": False}
2216
2215
 
2217
2216
 
2218
- def not_(expression: ExpOrStr, dialect: DialectType = None, copy: bool = True, **opts) -> Not:
2217
+ def not_(
2218
+ expression: ExpOrStr, dialect: DialectType = None, copy: bool = True, **opts: object
2219
+ ) -> Not:
2219
2220
  """
2220
2221
  Wrap a condition with a NOT operator.
2221
2222
 
@@ -2375,11 +2376,11 @@ TIMESTAMP_PARTS = {
2375
2376
  def maybe_parse(
2376
2377
  sql_or_expression: ExpOrStr,
2377
2378
  *,
2378
- into: t.Type[E],
2379
+ into: Type[E],
2379
2380
  dialect: DialectType = None,
2380
2381
  prefix: t.Optional[str] = None,
2381
2382
  copy: bool = False,
2382
- **opts,
2383
+ **opts: object,
2383
2384
  ) -> E: ...
2384
2385
 
2385
2386
 
@@ -2391,7 +2392,7 @@ def maybe_parse(
2391
2392
  dialect: DialectType = None,
2392
2393
  prefix: t.Optional[str] = None,
2393
2394
  copy: bool = False,
2394
- **opts,
2395
+ **opts: object,
2395
2396
  ) -> E: ...
2396
2397
 
2397
2398
 
@@ -2402,7 +2403,7 @@ def maybe_parse(
2402
2403
  dialect: DialectType = None,
2403
2404
  prefix: t.Optional[str] = None,
2404
2405
  copy: bool = False,
2405
- **opts: t.Any,
2406
+ **opts: object,
2406
2407
  ) -> Expr:
2407
2408
  """Gracefully handle a possible string or expression.
2408
2409
 
@@ -2508,7 +2509,7 @@ def _apply_builder(
2508
2509
  into=None,
2509
2510
  dialect=None,
2510
2511
  into_arg="this",
2511
- **opts,
2512
+ **opts: t.Any,
2512
2513
  ):
2513
2514
  if _is_wrong_expression(expression, into):
2514
2515
  expression = into(**{into_arg: expression})
@@ -2534,7 +2535,7 @@ def _apply_child_list_builder(
2534
2535
  into=None,
2535
2536
  dialect=None,
2536
2537
  properties=None,
2537
- **opts,
2538
+ **opts: t.Any,
2538
2539
  ):
2539
2540
  instance = maybe_copy(instance, copy)
2540
2541
  parsed = []
@@ -2579,7 +2580,7 @@ def _apply_list_builder(
2579
2580
  prefix=None,
2580
2581
  into=None,
2581
2582
  dialect=None,
2582
- **opts,
2583
+ **opts: t.Any,
2583
2584
  ):
2584
2585
  inst = maybe_copy(instance, copy)
2585
2586
 
@@ -2611,7 +2612,7 @@ def _apply_conjunction_builder(
2611
2612
  append=True,
2612
2613
  copy=True,
2613
2614
  dialect=None,
2614
- **opts,
2615
+ **opts: t.Any,
2615
2616
  ):
2616
2617
  filtered = [exp for exp in expressions if exp is not None and exp != ""]
2617
2618
  if not filtered:
@@ -2630,12 +2631,12 @@ def _apply_conjunction_builder(
2630
2631
 
2631
2632
 
2632
2633
  def _combine(
2633
- expressions: t.Sequence[t.Optional[ExpOrStr]],
2634
+ expressions: Sequence[t.Optional[ExpOrStr]],
2634
2635
  operator: t.Any,
2635
2636
  dialect: DialectType = None,
2636
2637
  copy: bool = True,
2637
2638
  wrap: bool = True,
2638
- **opts,
2639
+ **opts: object,
2639
2640
  ) -> Expr:
2640
2641
  conditions = [
2641
2642
  condition(expression, dialect=dialect, copy=copy, **opts)
@@ -2653,24 +2654,24 @@ def _combine(
2653
2654
 
2654
2655
 
2655
2656
  @t.overload
2656
- def _wrap(expression: None, kind: t.Type[Expr]) -> None: ...
2657
+ def _wrap(expression: None, kind: Type[Expr]) -> None: ...
2657
2658
 
2658
2659
 
2659
2660
  @t.overload
2660
- def _wrap(expression: E, kind: t.Type[Expr]) -> E | Paren: ...
2661
+ def _wrap(expression: E, kind: Type[Expr]) -> E | Paren: ...
2661
2662
 
2662
2663
 
2663
- def _wrap(expression: t.Optional[E], kind: t.Type[Expr]) -> t.Optional[E] | Paren:
2664
+ def _wrap(expression: t.Optional[E], kind: Type[Expr]) -> t.Optional[E] | Paren:
2664
2665
  return Paren(this=expression) if isinstance(expression, kind) else expression
2665
2666
 
2666
2667
 
2667
2668
  def _apply_set_operation(
2668
2669
  *expressions: ExpOrStr,
2669
- set_operation: t.Type,
2670
+ set_operation: Type,
2670
2671
  distinct: bool = True,
2671
2672
  dialect: DialectType = None,
2672
2673
  copy: bool = True,
2673
- **opts,
2674
+ **opts: t.Any,
2674
2675
  ) -> t.Any:
2675
2676
  return reduce(
2676
2677
  lambda x, y: set_operation(this=x, expression=y, distinct=distinct, **opts),
@@ -2718,7 +2719,9 @@ def to_identifier(name, quoted=None, copy=True):
2718
2719
  return identifier
2719
2720
 
2720
2721
 
2721
- def condition(expression: ExpOrStr, dialect: DialectType = None, copy: bool = True, **opts) -> Expr:
2722
+ def condition(
2723
+ expression: ExpOrStr, dialect: DialectType = None, copy: bool = True, **opts: t.Any
2724
+ ) -> Expr:
2722
2725
  """
2723
2726
  Initialize a logical condition expression.
2724
2727
 
@@ -2758,7 +2761,7 @@ def and_(
2758
2761
  dialect: DialectType = None,
2759
2762
  copy: bool = True,
2760
2763
  wrap: bool = True,
2761
- **opts,
2764
+ **opts: object,
2762
2765
  ) -> Condition:
2763
2766
  """
2764
2767
  Combine multiple conditions with an AND logical operator.
@@ -2788,7 +2791,7 @@ def or_(
2788
2791
  dialect: DialectType = None,
2789
2792
  copy: bool = True,
2790
2793
  wrap: bool = True,
2791
- **opts,
2794
+ **opts: object,
2792
2795
  ) -> Condition:
2793
2796
  """
2794
2797
  Combine multiple conditions with an OR logical operator.
@@ -2818,7 +2821,7 @@ def xor(
2818
2821
  dialect: DialectType = None,
2819
2822
  copy: bool = True,
2820
2823
  wrap: bool = True,
2821
- **opts,
2824
+ **opts: object,
2822
2825
  ) -> Condition:
2823
2826
  """
2824
2827
  Combine multiple conditions with an XOR logical operator.
@@ -2865,11 +2868,11 @@ def paren(expression: ExpOrStr, copy: bool = True) -> Paren:
2865
2868
  def alias_(
2866
2869
  expression: ExpOrStr,
2867
2870
  alias: t.Optional[str | Identifier],
2868
- table: bool | t.Sequence[str | Identifier] = False,
2871
+ table: bool | Sequence[str | Identifier] = False,
2869
2872
  quoted: t.Optional[bool] = None,
2870
2873
  dialect: DialectType = None,
2871
2874
  copy: bool = True,
2872
- **opts,
2875
+ **opts: t.Any,
2873
2876
  ) -> Expr:
2874
2877
  """Create an Alias expression.
2875
2878
 
@@ -2928,7 +2931,7 @@ def column(
2928
2931
  db: t.Optional[str | Identifier] = None,
2929
2932
  catalog: t.Optional[str | Identifier] = None,
2930
2933
  *,
2931
- fields: t.Collection[t.Union[str, Identifier]],
2934
+ fields: Collection[t.Union[str, Identifier]],
2932
2935
  quoted: t.Optional[bool] = None,
2933
2936
  copy: bool = True,
2934
2937
  ) -> Dot: