sqlglotc 30.26.0__tar.gz → 30.27.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 (117) hide show
  1. {sqlglotc-30.26.0/sqlglotc.egg-info → sqlglotc-30.27.0}/PKG-INFO +2 -2
  2. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/datatypes.py +1 -0
  3. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/sqlite.py +23 -14
  4. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parser.py +9 -0
  5. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/duckdb.py +12 -1
  6. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/tokenizer_core.py +1 -0
  7. {sqlglotc-30.26.0 → sqlglotc-30.27.0/sqlglotc.egg-info}/PKG-INFO +2 -2
  8. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglotc.egg-info/requires.txt +1 -1
  9. sqlglotc-30.27.0/sqlglotc.egg-info/scm_version.json +8 -0
  10. sqlglotc-30.26.0/sqlglotc.egg-info/scm_version.json +0 -8
  11. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/MANIFEST.in +0 -0
  12. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/pyproject.toml +0 -0
  13. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/setup.cfg +0 -0
  14. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/setup.py +0 -0
  15. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/anonymize.py +0 -0
  16. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/errors.py +0 -0
  17. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/executor/table.py +0 -0
  18. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/aggregate.py +0 -0
  19. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/array.py +0 -0
  20. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/builders.py +0 -0
  21. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/constraints.py +0 -0
  22. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/core.py +0 -0
  23. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/ddl.py +0 -0
  24. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/dml.py +0 -0
  25. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/functions.py +0 -0
  26. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/json.py +0 -0
  27. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/math.py +0 -0
  28. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/properties.py +0 -0
  29. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/query.py +0 -0
  30. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/string.py +0 -0
  31. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/expressions/temporal.py +0 -0
  32. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generator.py +0 -0
  33. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/athena.py +0 -0
  34. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/bigquery.py +0 -0
  35. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/clickhouse.py +0 -0
  36. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/databricks.py +0 -0
  37. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/dax.py +0 -0
  38. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/doris.py +0 -0
  39. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/dremio.py +0 -0
  40. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/drill.py +0 -0
  41. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/druid.py +0 -0
  42. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/duckdb.py +0 -0
  43. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/dune.py +0 -0
  44. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/exasol.py +0 -0
  45. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/fabric.py +0 -0
  46. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/hive.py +0 -0
  47. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/materialize.py +0 -0
  48. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/mysql.py +0 -0
  49. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/oracle.py +0 -0
  50. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/postgres.py +0 -0
  51. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/presto.py +0 -0
  52. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/prql.py +0 -0
  53. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/python.py +0 -0
  54. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/redshift.py +0 -0
  55. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/risingwave.py +0 -0
  56. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/singlestore.py +0 -0
  57. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/snowflake.py +0 -0
  58. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/solr.py +0 -0
  59. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/spark.py +0 -0
  60. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/spark2.py +0 -0
  61. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/starrocks.py +0 -0
  62. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/tableau.py +0 -0
  63. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/teradata.py +0 -0
  64. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/trino.py +0 -0
  65. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/generators/tsql.py +0 -0
  66. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/helper.py +0 -0
  67. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/lineage.py +0 -0
  68. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/optimizer/annotate_types.py +0 -0
  69. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/optimizer/canonicalize_internal_names.py +0 -0
  70. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/optimizer/isolate_table_selects.py +0 -0
  71. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/optimizer/normalize_identifiers.py +0 -0
  72. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/optimizer/qualify.py +0 -0
  73. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/optimizer/qualify_columns.py +0 -0
  74. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/optimizer/qualify_tables.py +0 -0
  75. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/optimizer/resolver.py +0 -0
  76. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/optimizer/scope.py +0 -0
  77. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/optimizer/simplify.py +0 -0
  78. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/athena.py +0 -0
  79. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/base.py +0 -0
  80. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/bigquery.py +0 -0
  81. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/clickhouse.py +0 -0
  82. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/databricks.py +0 -0
  83. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/dax.py +0 -0
  84. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/doris.py +0 -0
  85. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/dremio.py +0 -0
  86. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/drill.py +0 -0
  87. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/druid.py +0 -0
  88. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/dune.py +0 -0
  89. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/exasol.py +0 -0
  90. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/fabric.py +0 -0
  91. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/hive.py +0 -0
  92. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/materialize.py +0 -0
  93. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/mysql.py +0 -0
  94. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/oracle.py +0 -0
  95. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/postgres.py +0 -0
  96. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/presto.py +0 -0
  97. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/prql.py +0 -0
  98. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/redshift.py +0 -0
  99. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/risingwave.py +0 -0
  100. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/singlestore.py +0 -0
  101. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/snowflake.py +0 -0
  102. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/solr.py +0 -0
  103. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/spark.py +0 -0
  104. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/spark2.py +0 -0
  105. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/sqlite.py +0 -0
  106. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/starrocks.py +0 -0
  107. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/tableau.py +0 -0
  108. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/teradata.py +0 -0
  109. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/trino.py +0 -0
  110. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/parsers/tsql.py +0 -0
  111. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/serde.py +0 -0
  112. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/time.py +0 -0
  113. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglot/trie.py +0 -0
  114. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglotc.egg-info/SOURCES.txt +0 -0
  115. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglotc.egg-info/dependency_links.txt +0 -0
  116. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglotc.egg-info/scm_file_list.json +0 -0
  117. {sqlglotc-30.26.0 → sqlglotc-30.27.0}/sqlglotc.egg-info/top_level.txt +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlglotc
3
- Version: 30.26.0
3
+ Version: 30.27.0
4
4
  Summary: mypyc-compiled extensions for sqlglot
5
5
  Author-email: Toby Mao <toby.mao@gmail.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://sqlglot.com/
8
8
  Project-URL: Repository, https://github.com/tobymao/sqlglot
9
9
  Requires-Python: >=3.10
10
- Requires-Dist: sqlglot==30.26.0
10
+ Requires-Dist: sqlglot==30.27.0
11
11
  Provides-Extra: dev
12
12
  Requires-Dist: setuptools>=61.0; extra == "dev"
13
13
  Requires-Dist: setuptools_scm>=10.2; extra == "dev"
@@ -117,6 +117,7 @@ class DType(AutoName):
117
117
  NVARCHAR = auto()
118
118
  OBJECT = auto()
119
119
  RANGE = auto()
120
+ REF = auto()
120
121
  ROWVERSION = auto()
121
122
  SERIAL = auto()
122
123
  SET = auto()
@@ -81,19 +81,6 @@ def _generated_to_auto_increment(expression: exp.Expr) -> exp.Expr:
81
81
  return expression
82
82
 
83
83
 
84
- def _offset_to_limit(expression: exp.Expr) -> exp.Expr:
85
- if not isinstance(expression, exp.Select):
86
- return expression
87
-
88
- offset = expression.args.get("offset")
89
- limit = expression.args.get("limit")
90
-
91
- if offset and (not limit or (isinstance(limit, exp.Limit) and limit.is_limit_all)):
92
- expression.limit(-1, copy=False)
93
-
94
- return expression
95
-
96
-
97
84
  class SQLiteGenerator(generator.Generator):
98
85
  SELECT_KINDS: tuple[str, ...] = ()
99
86
  TRY_SUPPORTED = False
@@ -173,7 +160,6 @@ class SQLiteGenerator(generator.Generator):
173
160
  exp.RegexpLike: lambda self, e: self.binary(e, "REGEXP"),
174
161
  exp.Select: transforms.preprocess(
175
162
  [
176
- _offset_to_limit,
177
163
  transforms.eliminate_distinct_on,
178
164
  transforms.eliminate_qualify,
179
165
  transforms.eliminate_semi_and_anti_joins,
@@ -204,6 +190,29 @@ class SQLiteGenerator(generator.Generator):
204
190
 
205
191
  LIMIT_FETCH = "LIMIT"
206
192
 
193
+ def offset_limit_modifiers(
194
+ self, expression: exp.Expr, fetch: bool, limit: exp.Fetch | exp.Limit | None
195
+ ) -> list[str]:
196
+ if expression.args.get("offset") and (
197
+ not limit or (isinstance(limit, exp.Limit) and limit.is_limit_all)
198
+ ):
199
+ limit = exp.Limit(expression=exp.Literal.number(-1))
200
+ return super().offset_limit_modifiers(expression, fetch, limit)
201
+
202
+ def subquery_sql(self, expression: exp.Subquery, sep: str = " AS ") -> str:
203
+ if any(expression.args.get(key) for key in ("order", "limit", "offset")):
204
+ query = expression.this
205
+ keys = ("order", "limit", "offset", "with_")
206
+ # Merge grouping modifiers unless doing so would overwrite an inner clause.
207
+ if any(expression.args.get(key) and query.args.get(key) for key in keys):
208
+ query = exp.select("*").from_(query.subquery(copy=False), copy=False)
209
+ for key in keys:
210
+ if value := expression.args.get(key):
211
+ query.set(key, value.pop())
212
+ return self.sql(query)
213
+
214
+ return super().subquery_sql(expression, sep=sep)
215
+
207
216
  def autoincrementcolumnconstraint_sql(
208
217
  self, expression: exp.AutoIncrementColumnConstraint
209
218
  ) -> str:
@@ -646,6 +646,7 @@ class Parser:
646
646
  TokenType.VOID,
647
647
  TokenType.OBJECT,
648
648
  TokenType.OBJECT_IDENTIFIER,
649
+ TokenType.REF,
649
650
  TokenType.INET,
650
651
  TokenType.IPADDRESS,
651
652
  TokenType.IPPREFIX,
@@ -799,6 +800,7 @@ class Parser:
799
800
  TokenType.FULL,
800
801
  TokenType.GET,
801
802
  TokenType.IDENTIFIER,
803
+ TokenType.IN,
802
804
  TokenType.INOUT,
803
805
  TokenType.IS,
804
806
  TokenType.ISNULL,
@@ -6869,6 +6871,13 @@ class Parser:
6869
6871
  return this
6870
6872
  elif type_token in self.ENUM_TYPE_TOKENS:
6871
6873
  expressions = self._parse_csv(self._parse_equality)
6874
+ elif type_token == TokenType.REF:
6875
+ # REF(schema.customer) names a target; REF(1) can still be a function call.
6876
+ target = self._try_parse(lambda: self._parse_table_parts(schema=True))
6877
+ if target is None:
6878
+ self._retreat(index)
6879
+ return None
6880
+ expressions = [target]
6872
6881
  elif type_token == TokenType.JSON:
6873
6882
  # ClickHouse JSON type supports arguments: JSON(col Type, SKIP col, param=value)
6874
6883
  # https://clickhouse.com/docs/sql-reference/data-types/newjson
@@ -105,6 +105,10 @@ def _convert_text_type(dtype: exp.DataType) -> exp.DataType:
105
105
  return dtype
106
106
 
107
107
 
108
+ _parse_regexp_like = binary_range_parser(exp.RegexpLike)
109
+ _parse_regexp_full_match = binary_range_parser(exp.RegexpFullMatch)
110
+
111
+
108
112
  class DuckDBParser(parser.Parser):
109
113
  IS_PREDICATE_PRECEDENCE = IsPredicatePrecedence.LOW
110
114
 
@@ -139,7 +143,7 @@ class DuckDBParser(parser.Parser):
139
143
  RANGE_PARSERS = {
140
144
  **parser.Parser.RANGE_PARSERS,
141
145
  TokenType.DAMP: binary_range_parser(exp.ArrayOverlaps),
142
- TokenType.TILDE: binary_range_parser(exp.RegexpFullMatch),
146
+ TokenType.TILDE: lambda self, this: self._parse_tilde(this),
143
147
  }
144
148
 
145
149
  EXPONENT = {
@@ -312,6 +316,13 @@ class DuckDBParser(parser.Parser):
312
316
  SHOW_TRIE = new_trie(key.split(" ") for key in SHOW_PARSERS)
313
317
  SET_TRIE = new_trie(key.split(" ") for key in SET_PARSERS)
314
318
 
319
+ def _parse_tilde(self, this: exp.Expr | None) -> exp.Expr | None:
320
+ # ~ and !~ match anywhere in the string since DuckDB 2.0, and the whole string before it
321
+ # https://duckdb.org/docs/2.0/sql/functions/pattern_matching
322
+ if self.dialect.version >= (2, 0):
323
+ return _parse_regexp_like(self, this)
324
+ return _parse_regexp_full_match(self, this)
325
+
315
326
  def _parse_trigger_execute(self) -> exp.Expr | None:
316
327
  body = self._try_parse(self._parse_statement)
317
328
  return body if not self._curr else None
@@ -219,6 +219,7 @@ class TokenType(IntEnum):
219
219
  IMAGE = auto()
220
220
  VARIANT = auto()
221
221
  OBJECT = auto()
222
+ REF = auto()
222
223
  INET = auto()
223
224
  IPADDRESS = auto()
224
225
  IPPREFIX = auto()
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlglotc
3
- Version: 30.26.0
3
+ Version: 30.27.0
4
4
  Summary: mypyc-compiled extensions for sqlglot
5
5
  Author-email: Toby Mao <toby.mao@gmail.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://sqlglot.com/
8
8
  Project-URL: Repository, https://github.com/tobymao/sqlglot
9
9
  Requires-Python: >=3.10
10
- Requires-Dist: sqlglot==30.26.0
10
+ Requires-Dist: sqlglot==30.27.0
11
11
  Provides-Extra: dev
12
12
  Requires-Dist: setuptools>=61.0; extra == "dev"
13
13
  Requires-Dist: setuptools_scm>=10.2; extra == "dev"
@@ -1,4 +1,4 @@
1
- sqlglot==30.26.0
1
+ sqlglot==30.27.0
2
2
 
3
3
  [dev]
4
4
  setuptools>=61.0
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "30.27.0",
3
+ "distance": 0,
4
+ "node": "g98782638dd6dbdedebad0e6ff6edc6e69598b81e",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-10-30"
8
+ }
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "30.26.0",
3
- "distance": 0,
4
- "node": "gb0842a1ee0be2cc9345d7312724dbf2ee32e325a",
5
- "dirty": false,
6
- "branch": "HEAD",
7
- "node_date": "2026-10-29"
8
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes