sqlglotc 30.5.0__tar.gz → 30.6.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.

Potentially problematic release.


This version of sqlglotc might be problematic. Click here for more details.

Files changed (111) hide show
  1. {sqlglotc-30.5.0/sqlglotc.egg-info → sqlglotc-30.6.0}/PKG-INFO +1 -1
  2. sqlglotc-30.6.0/sqlglot/generators/python.py +108 -0
  3. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parser.py +1 -1
  4. {sqlglotc-30.5.0 → sqlglotc-30.6.0/sqlglotc.egg-info}/PKG-INFO +1 -1
  5. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglotc.egg-info/SOURCES.txt +1 -0
  6. sqlglotc-30.6.0/sqlglotc.egg-info/top_level.txt +2 -0
  7. sqlglotc-30.5.0/sqlglotc.egg-info/top_level.txt +0 -2
  8. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/MANIFEST.in +0 -0
  9. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/pyproject.toml +0 -0
  10. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/setup.cfg +0 -0
  11. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/setup.py +0 -0
  12. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/errors.py +0 -0
  13. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/executor/table.py +0 -0
  14. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/aggregate.py +0 -0
  15. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/array.py +0 -0
  16. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/builders.py +0 -0
  17. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/constraints.py +0 -0
  18. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/core.py +0 -0
  19. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/datatypes.py +0 -0
  20. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/ddl.py +0 -0
  21. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/dml.py +0 -0
  22. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/functions.py +0 -0
  23. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/json.py +0 -0
  24. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/math.py +0 -0
  25. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/properties.py +0 -0
  26. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/query.py +0 -0
  27. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/string.py +0 -0
  28. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/expressions/temporal.py +0 -0
  29. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generator.py +0 -0
  30. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/athena.py +0 -0
  31. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/bigquery.py +0 -0
  32. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/clickhouse.py +0 -0
  33. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/databricks.py +0 -0
  34. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/doris.py +0 -0
  35. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/dremio.py +0 -0
  36. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/drill.py +0 -0
  37. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/druid.py +0 -0
  38. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/duckdb.py +0 -0
  39. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/dune.py +0 -0
  40. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/exasol.py +0 -0
  41. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/fabric.py +0 -0
  42. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/hive.py +0 -0
  43. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/materialize.py +0 -0
  44. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/mysql.py +0 -0
  45. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/oracle.py +0 -0
  46. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/postgres.py +0 -0
  47. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/presto.py +0 -0
  48. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/prql.py +0 -0
  49. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/redshift.py +0 -0
  50. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/risingwave.py +0 -0
  51. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/singlestore.py +0 -0
  52. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/snowflake.py +0 -0
  53. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/solr.py +0 -0
  54. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/spark.py +0 -0
  55. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/spark2.py +0 -0
  56. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/sqlite.py +0 -0
  57. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/starrocks.py +0 -0
  58. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/tableau.py +0 -0
  59. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/teradata.py +0 -0
  60. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/trino.py +0 -0
  61. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/generators/tsql.py +0 -0
  62. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/helper.py +0 -0
  63. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/optimizer/annotate_types.py +0 -0
  64. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/optimizer/isolate_table_selects.py +0 -0
  65. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/optimizer/normalize_identifiers.py +0 -0
  66. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/optimizer/qualify.py +0 -0
  67. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/optimizer/qualify_columns.py +0 -0
  68. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/optimizer/qualify_tables.py +0 -0
  69. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/optimizer/resolver.py +0 -0
  70. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/optimizer/scope.py +0 -0
  71. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/optimizer/simplify.py +0 -0
  72. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/athena.py +0 -0
  73. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/base.py +0 -0
  74. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/bigquery.py +0 -0
  75. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/clickhouse.py +0 -0
  76. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/databricks.py +0 -0
  77. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/doris.py +0 -0
  78. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/dremio.py +0 -0
  79. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/drill.py +0 -0
  80. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/druid.py +0 -0
  81. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/duckdb.py +0 -0
  82. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/dune.py +0 -0
  83. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/exasol.py +0 -0
  84. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/fabric.py +0 -0
  85. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/hive.py +0 -0
  86. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/materialize.py +0 -0
  87. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/mysql.py +0 -0
  88. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/oracle.py +0 -0
  89. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/postgres.py +0 -0
  90. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/presto.py +0 -0
  91. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/prql.py +0 -0
  92. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/redshift.py +0 -0
  93. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/risingwave.py +0 -0
  94. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/singlestore.py +0 -0
  95. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/snowflake.py +0 -0
  96. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/solr.py +0 -0
  97. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/spark.py +0 -0
  98. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/spark2.py +0 -0
  99. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/sqlite.py +0 -0
  100. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/starrocks.py +0 -0
  101. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/tableau.py +0 -0
  102. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/teradata.py +0 -0
  103. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/trino.py +0 -0
  104. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/parsers/tsql.py +0 -0
  105. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/schema.py +0 -0
  106. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/serde.py +0 -0
  107. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/time.py +0 -0
  108. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/tokenizer_core.py +0 -0
  109. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglot/trie.py +0 -0
  110. {sqlglotc-30.5.0 → sqlglotc-30.6.0}/sqlglotc.egg-info/dependency_links.txt +0 -0
  111. {sqlglotc-30.5.0 → sqlglotc-30.6.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.5.0
3
+ Version: 30.6.0
4
4
  Summary: mypyc-compiled extensions for sqlglot
5
5
  Author-email: Toby Mao <toby.mao@gmail.com>
6
6
  License-Expression: MIT
@@ -0,0 +1,108 @@
1
+ from __future__ import annotations
2
+
3
+ import itertools
4
+
5
+ from sqlglot import exp, generator
6
+ from sqlglot.dialects.dialect import inline_array_sql
7
+ from sqlglot.helper import subclasses
8
+
9
+
10
+ def _ordered_py(self, expression):
11
+ this = self.sql(expression, "this")
12
+ desc = "True" if expression.args.get("desc") else "False"
13
+ nulls_first = "True" if expression.args.get("nulls_first") else "False"
14
+ return f"ORDERED({this}, {desc}, {nulls_first})"
15
+
16
+
17
+ def _rename(self, e):
18
+ try:
19
+ values = list(e.args.values())
20
+
21
+ if len(values) == 1:
22
+ values = values[0]
23
+ if not isinstance(values, list):
24
+ return self.func(e.key, values)
25
+ return self.func(e.key, *values)
26
+
27
+ if isinstance(e, exp.Func) and e.is_var_len_args:
28
+ args = itertools.chain.from_iterable(x if isinstance(x, list) else [x] for x in values)
29
+ return self.func(e.key, *args)
30
+
31
+ return self.func(e.key, *values)
32
+ except Exception as ex:
33
+ raise Exception(f"Could not rename {repr(e)}") from ex
34
+
35
+
36
+ def _case_sql(self, expression):
37
+ this = self.sql(expression, "this")
38
+ chain = self.sql(expression, "default") or "None"
39
+
40
+ for e in reversed(expression.args["ifs"]):
41
+ true = self.sql(e, "true")
42
+ condition = self.sql(e, "this")
43
+ condition = f"{this} = ({condition})" if this else condition
44
+ chain = f"{true} if {condition} else ({chain})"
45
+
46
+ return chain
47
+
48
+
49
+ def _lambda_sql(self, e: exp.Lambda) -> str:
50
+ names = {e.name.lower() for e in e.expressions}
51
+
52
+ e = e.transform(
53
+ lambda n: (
54
+ exp.var(n.name) if isinstance(n, exp.Identifier) and n.name.lower() in names else n
55
+ )
56
+ ).assert_is(exp.Lambda)
57
+
58
+ return f"lambda {self.expressions(e, flat=True)}: {self.sql(e, 'this')}"
59
+
60
+
61
+ def _div_sql(self: generator.Generator, e: exp.Div) -> str:
62
+ denominator = self.sql(e, "expression")
63
+
64
+ if e.args.get("safe"):
65
+ denominator += " or None"
66
+
67
+ sql = f"DIV({self.sql(e, 'this')}, {denominator})"
68
+
69
+ if e.args.get("typed"):
70
+ sql = f"int({sql})"
71
+
72
+ return sql
73
+
74
+
75
+ class PythonGenerator(generator.Generator):
76
+ TRANSFORMS = {
77
+ **{klass: _rename for klass in subclasses(exp.__name__, exp.Binary)},
78
+ **{klass: _rename for klass in exp.ALL_FUNCTIONS},
79
+ exp.Case: _case_sql,
80
+ exp.Alias: lambda self, e: self.sql(e.this),
81
+ exp.Array: inline_array_sql,
82
+ exp.And: lambda self, e: self.binary(e, "and"),
83
+ exp.Between: _rename,
84
+ exp.Boolean: lambda self, e: "True" if e.this else "False",
85
+ exp.Cast: lambda self, e: f"CAST({self.sql(e.this)}, exp.DType.{e.args['to']})",
86
+ exp.Column: lambda self, e: f"scope[{self.sql(e, 'table') or None}][{self.sql(e.this)}]",
87
+ exp.Concat: lambda self, e: self.func(
88
+ "SAFECONCAT" if e.args.get("safe") else "CONCAT", *e.expressions
89
+ ),
90
+ exp.Distinct: lambda self, e: f"set({self.sql(e, 'this')})",
91
+ exp.Div: _div_sql,
92
+ exp.Extract: lambda self, e: f"EXTRACT('{e.name.lower()}', {self.sql(e, 'expression')})",
93
+ exp.In: lambda self, e: f"{self.sql(e, 'this')} in {{{self.expressions(e, flat=True)}}}",
94
+ exp.Interval: lambda self, e: f"INTERVAL({self.sql(e.this)}, '{self.sql(e.unit)}')",
95
+ exp.Is: lambda self, e: (
96
+ self.binary(e, "==") if isinstance(e.this, exp.Literal) else self.binary(e, "is")
97
+ ),
98
+ exp.JSONExtract: lambda self, e: self.func(e.key, e.this, e.expression, *e.expressions),
99
+ exp.JSONPath: lambda self, e: f"[{','.join(self.sql(p) for p in e.expressions[1:])}]",
100
+ exp.JSONPathKey: lambda self, e: f"'{self.sql(e.this)}'",
101
+ exp.JSONPathSubscript: lambda self, e: f"'{e.this}'",
102
+ exp.Lambda: _lambda_sql,
103
+ exp.Not: lambda self, e: f"not {self.sql(e.this)}",
104
+ exp.Null: lambda *_: "None",
105
+ exp.Or: lambda self, e: self.binary(e, "or"),
106
+ exp.Ordered: _ordered_py,
107
+ exp.Star: lambda *_: "1",
108
+ }
@@ -2688,7 +2688,7 @@ class Parser:
2688
2688
  if not self._match_set((TokenType.FUNCTION, TokenType.PROCEDURE)):
2689
2689
  self.raise_error("Expected FUNCTION or PROCEDURE after EXECUTE")
2690
2690
 
2691
- func_call = self._parse_function(anonymous=True, optional_parens=False)
2691
+ func_call = self._parse_column()
2692
2692
  return self.expression(exp.TriggerExecute(this=func_call))
2693
2693
 
2694
2694
  def _parse_property_before(self) -> exp.Expr | list[exp.Expr] | None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlglotc
3
- Version: 30.5.0
3
+ Version: 30.6.0
4
4
  Summary: mypyc-compiled extensions for sqlglot
5
5
  Author-email: Toby Mao <toby.mao@gmail.com>
6
6
  License-Expression: MIT
@@ -45,6 +45,7 @@ sqlglot/generators/oracle.py
45
45
  sqlglot/generators/postgres.py
46
46
  sqlglot/generators/presto.py
47
47
  sqlglot/generators/prql.py
48
+ sqlglot/generators/python.py
48
49
  sqlglot/generators/redshift.py
49
50
  sqlglot/generators/risingwave.py
50
51
  sqlglot/generators/singlestore.py
@@ -0,0 +1,2 @@
1
+ c4b97c688323154f5bad__mypyc
2
+ sqlglot
@@ -1,2 +0,0 @@
1
- 869485d9470a3db4bb57__mypyc
2
- sqlglot
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
File without changes