sqlleaf 0.0.4__py3-none-any.whl → 0.0.5__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.
- sqlleaf/mappings.py +100 -43
- sqlleaf/models/query/base.py +1 -1
- sqlleaf/models/query/copy.py +2 -2
- sqlleaf/models/query/open.py +1 -1
- sqlleaf/processors/collector/collector.py +11 -4
- sqlleaf/processors/generator/dialects/base.py +3 -3
- sqlleaf/processors/substitutor/substitute.py +39 -13
- sqlleaf/processors/transformer/base.py +32 -44
- sqlleaf/processors/transformer/copy.py +4 -4
- sqlleaf/processors/transformer/ctas.py +2 -3
- sqlleaf/processors/transformer/delete.py +2 -1
- sqlleaf/processors/transformer/expressions/functional_notation.py +1 -2
- sqlleaf/processors/transformer/expressions/row.py +1 -2
- sqlleaf/processors/transformer/for_in.py +1 -1
- sqlleaf/processors/transformer/insert.py +3 -4
- sqlleaf/processors/transformer/merge.py +2 -1
- sqlleaf/processors/transformer/open.py +2 -2
- sqlleaf/processors/transformer/transformer.py +9 -9
- sqlleaf/processors/transformer/unload.py +1 -1
- sqlleaf/processors/transformer/update.py +4 -5
- sqlleaf/typing.py +2 -13
- sqlleaf/util/expression.py +3 -3
- {sqlleaf-0.0.4.dist-info → sqlleaf-0.0.5.dist-info}/METADATA +1 -1
- {sqlleaf-0.0.4.dist-info → sqlleaf-0.0.5.dist-info}/RECORD +27 -27
- {sqlleaf-0.0.4.dist-info → sqlleaf-0.0.5.dist-info}/WHEEL +0 -0
- {sqlleaf-0.0.4.dist-info → sqlleaf-0.0.5.dist-info}/licenses/LICENSE +0 -0
- {sqlleaf-0.0.4.dist-info → sqlleaf-0.0.5.dist-info}/top_level.txt +0 -0
sqlleaf/mappings.py
CHANGED
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
import typing as t
|
|
5
|
+
from dataclasses import dataclass, field
|
|
5
6
|
|
|
6
7
|
from sqlglot import MappingSchema, exp
|
|
7
8
|
from sqlglot.dialects.dialect import DialectType
|
|
@@ -34,57 +35,89 @@ FunctionCallable = ProcedureQuery | UserDefinedFunctionQuery
|
|
|
34
35
|
logger = logging.getLogger("sqlleaf")
|
|
35
36
|
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
@dataclass
|
|
39
|
+
class ParamBinding:
|
|
40
|
+
"""One parameter's binding for the lifetime of a single CALL."""
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
like qualification and simplification).
|
|
44
|
-
"""
|
|
42
|
+
value: exp.Expr
|
|
43
|
+
arg_name: str | None = None
|
|
45
44
|
|
|
46
|
-
def __init__(self, dialect: str):
|
|
47
|
-
super().__init__(
|
|
48
|
-
dialect=dialect, normalize=False
|
|
49
|
-
) # Set `normalize=False` to prevent an unnecessary second parse.
|
|
50
|
-
self.kind_mapping = {}
|
|
51
|
-
self.kind_mapping_trie = {}
|
|
52
|
-
# Session/global variables (e.g., SET var = ...)
|
|
53
|
-
self.session_variables: dict[str, exp.Expr] = {}
|
|
54
|
-
# Block-scoped variables: one dict per active block, innermost scope at the end
|
|
55
|
-
self.variable_scopes: list[dict[str, exp.Expr]] = []
|
|
56
45
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
@dataclass
|
|
47
|
+
class VariableScope:
|
|
48
|
+
"""One CALL boundary: its block stack and parameter bindings."""
|
|
49
|
+
|
|
50
|
+
blocks: list[dict[str, exp.Expr]] = field(default_factory=list)
|
|
51
|
+
bindings: dict[str, ParamBinding] = field(default_factory=dict)
|
|
61
52
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
|
|
54
|
+
class Variables:
|
|
55
|
+
def __init__(self):
|
|
56
|
+
# The base scope runs DO / top-level code and is never popped
|
|
57
|
+
self.scopes: list[VariableScope] = [VariableScope()]
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def _active_blocks(self) -> list[dict[str, exp.Expr]]:
|
|
61
|
+
return self.scopes[-1].blocks
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def _active_bindings(self) -> dict[str, ParamBinding]:
|
|
65
|
+
return self.scopes[-1].bindings
|
|
66
|
+
|
|
67
|
+
# ---- Block API ----
|
|
68
|
+
def push_block(self) -> None:
|
|
69
|
+
"""Enter a new DECLARE/BEGIN block."""
|
|
70
|
+
self._active_blocks.append({})
|
|
71
|
+
|
|
72
|
+
def pop_block(self) -> None:
|
|
73
|
+
"""Leave the current DECLARE/BEGIN block."""
|
|
74
|
+
if self._active_blocks:
|
|
75
|
+
self._active_blocks.pop()
|
|
76
|
+
|
|
77
|
+
# ---- Scope API ----
|
|
78
|
+
def push_scope(self, bindings: dict[str, ParamBinding]) -> None:
|
|
79
|
+
"""Enter a CALL boundary."""
|
|
80
|
+
self.scopes.append(VariableScope(bindings=bindings))
|
|
81
|
+
|
|
82
|
+
def pop_scope(self, write_back: bool = True) -> None:
|
|
83
|
+
"""Leave the current CALL boundary, optionally writing OUT/INOUT values back to the caller."""
|
|
84
|
+
if len(self.scopes) == 1:
|
|
85
|
+
raise exception.MappingError("Cannot pop the base variable scope")
|
|
86
|
+
scope = self.scopes.pop()
|
|
87
|
+
if write_back:
|
|
88
|
+
for binding in scope.bindings.values():
|
|
89
|
+
if binding.arg_name is not None:
|
|
90
|
+
self.set_variable(binding.arg_name, binding.value)
|
|
66
91
|
|
|
67
92
|
def declare_variable(self, name: str, value: exp.Expr | None = None) -> None:
|
|
68
|
-
"""Declare a variable in the current (innermost)
|
|
93
|
+
"""Declare a variable in the current (innermost) block."""
|
|
69
94
|
val = value if value is not None else exp.Null()
|
|
70
|
-
self.
|
|
71
|
-
logger.debug(f"Declared variable: {name} := {val
|
|
95
|
+
self._active_blocks[-1][name] = val
|
|
96
|
+
logger.debug(f"Declared variable: {name} := {val}")
|
|
72
97
|
|
|
73
98
|
def set_variable(self, name: str, value: exp.Expr) -> None:
|
|
74
|
-
"""Assign a variable in the nearest
|
|
75
|
-
for
|
|
76
|
-
if name in
|
|
77
|
-
|
|
78
|
-
logger.debug(f"Set variable value: {name} := {value
|
|
99
|
+
"""Assign a variable in the nearest block where it was declared."""
|
|
100
|
+
for block in reversed(self._active_blocks):
|
|
101
|
+
if name in block:
|
|
102
|
+
block[name] = value
|
|
103
|
+
logger.debug(f"Set variable value: {name} := {value}")
|
|
79
104
|
return
|
|
80
105
|
|
|
106
|
+
binding = self._active_bindings.get(name)
|
|
107
|
+
if binding is not None:
|
|
108
|
+
binding.value = value
|
|
109
|
+
return
|
|
110
|
+
|
|
81
111
|
raise exception.MappingError(f'"{name}" is not a known variable')
|
|
82
112
|
|
|
83
113
|
def get_variable(self, name: str, raise_on_missing: bool = True) -> exp.Expr | None:
|
|
84
|
-
"""Resolve a variable by searching from innermost
|
|
85
|
-
for
|
|
86
|
-
if name in
|
|
87
|
-
return
|
|
114
|
+
"""Resolve a variable by searching from innermost block outward, then the call's bindings."""
|
|
115
|
+
for block in reversed(self._active_blocks):
|
|
116
|
+
if name in block:
|
|
117
|
+
return block[name]
|
|
118
|
+
binding = self._active_bindings.get(name)
|
|
119
|
+
if binding is not None:
|
|
120
|
+
return binding.value
|
|
88
121
|
if raise_on_missing:
|
|
89
122
|
raise exception.MappingError(f"Could not find value for variable: {name}")
|
|
90
123
|
return None
|
|
@@ -110,8 +143,28 @@ class ObjectMapping(MappingSchema):
|
|
|
110
143
|
return resolved
|
|
111
144
|
|
|
112
145
|
def get_scope(self) -> dict[str, exp.Expr]:
|
|
113
|
-
"""Return the current
|
|
114
|
-
return self.
|
|
146
|
+
"""Return the current block dict (innermost)."""
|
|
147
|
+
return self._active_blocks[-1]
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class ObjectMapping(MappingSchema):
|
|
151
|
+
"""
|
|
152
|
+
Contains all the objects that get created, such as tables, procedures, functions, and sequences.
|
|
153
|
+
|
|
154
|
+
We extends sqlglot.MappingSchema to provide additional functionality related to tracking these objects,
|
|
155
|
+
while still allowing optimizer inside sqlglot to work (as it needs a mapping of objects to perform functions
|
|
156
|
+
like qualification and simplification).
|
|
157
|
+
"""
|
|
158
|
+
|
|
159
|
+
def __init__(self, dialect: str):
|
|
160
|
+
super().__init__(
|
|
161
|
+
dialect=dialect, normalize=False
|
|
162
|
+
) # Set `normalize=False` to prevent an unnecessary second parse.
|
|
163
|
+
self.kind_mapping = {}
|
|
164
|
+
self.kind_mapping_trie = {}
|
|
165
|
+
# Session/global variables (e.g., SET var = ...)
|
|
166
|
+
self.session_variables: dict[str, exp.Expr] = {}
|
|
167
|
+
self.variables = Variables()
|
|
115
168
|
|
|
116
169
|
def add_database_query(self, query: DatabaseQuery) -> None:
|
|
117
170
|
self._add_query(query=query, dialect=query.dialect)
|
|
@@ -356,7 +409,9 @@ class ObjectMapping(MappingSchema):
|
|
|
356
409
|
|
|
357
410
|
return resolve_overloaded_function(node, candidates)
|
|
358
411
|
|
|
359
|
-
def lookup_procedure_call(
|
|
412
|
+
def lookup_procedure_call(
|
|
413
|
+
self, node: CallQuery, args: list[exp.Expr] | None = None
|
|
414
|
+
) -> ProcedureQuery | None:
|
|
360
415
|
"""
|
|
361
416
|
Looks up the procedure definition for a CALL statement.
|
|
362
417
|
Returns the matched procedure definition, or None if no procedure with that name exists.
|
|
@@ -367,11 +422,11 @@ class ObjectMapping(MappingSchema):
|
|
|
367
422
|
return None
|
|
368
423
|
|
|
369
424
|
# Annotate copies so the call's own expressions are left untouched
|
|
370
|
-
|
|
371
|
-
for arg in
|
|
425
|
+
call_args = [arg.copy() for arg in (args if args is not None else node.args)]
|
|
426
|
+
for arg in call_args:
|
|
372
427
|
annotate_types(_get_call_arg_value(arg), dialect=self.dialect, schema=self)
|
|
373
428
|
|
|
374
|
-
return resolve_overloaded_procedure(
|
|
429
|
+
return resolve_overloaded_procedure(call_args, candidates)
|
|
375
430
|
|
|
376
431
|
|
|
377
432
|
def resolve_overloaded_function(
|
|
@@ -504,6 +559,8 @@ def match_callable_arguments(args: list[exp.Expr], params: list[FunctionParam])
|
|
|
504
559
|
if param.default is None and not param.is_variadic:
|
|
505
560
|
return False
|
|
506
561
|
elif param.is_input and not isinstance(bound[i], exp.Null):
|
|
562
|
+
if param.is_output and isinstance(bound[i], exp.Column) and not bound[i].table:
|
|
563
|
+
continue
|
|
507
564
|
if not _match_argument(bound[i], param.type):
|
|
508
565
|
return False
|
|
509
566
|
|
sqlleaf/models/query/base.py
CHANGED
|
@@ -11,7 +11,7 @@ from sqlglot import exp
|
|
|
11
11
|
from sqlglot.optimizer.annotate_types import annotate_types
|
|
12
12
|
|
|
13
13
|
from sqlleaf import exception, mappings, util
|
|
14
|
-
from sqlleaf.typing import
|
|
14
|
+
from sqlleaf.typing import SourceInfo, SqlObjectType, TargetInfo
|
|
15
15
|
|
|
16
16
|
logger = logging.getLogger("sqlleaf")
|
|
17
17
|
|
sqlleaf/models/query/copy.py
CHANGED
|
@@ -8,7 +8,7 @@ from sqlglot import exp
|
|
|
8
8
|
|
|
9
9
|
from sqlleaf import exception, mappings, util
|
|
10
10
|
from sqlleaf.models.query.base import Query
|
|
11
|
-
from sqlleaf.typing import
|
|
11
|
+
from sqlleaf.typing import SourceInfo, TargetInfo
|
|
12
12
|
|
|
13
13
|
logger = logging.getLogger("sqlleaf")
|
|
14
14
|
|
|
@@ -114,7 +114,7 @@ class CopyQuery(Query):
|
|
|
114
114
|
|
|
115
115
|
def get_source_and_target_expressions(
|
|
116
116
|
self, expr: exp.Copy, dialect: str
|
|
117
|
-
) -> tuple[
|
|
117
|
+
) -> tuple[exp.Expr, exp.Expr]:
|
|
118
118
|
"""
|
|
119
119
|
Determine the source and target expressions of the query.
|
|
120
120
|
"""
|
sqlleaf/models/query/open.py
CHANGED
|
@@ -48,7 +48,7 @@ class OpenQuery(Query):
|
|
|
48
48
|
[key]
|
|
49
49
|
"""
|
|
50
50
|
cursor_name = self.target()
|
|
51
|
-
cursor_expr = self.object_mapping.get_variable(name=cursor_name.name)
|
|
51
|
+
cursor_expr = self.object_mapping.variables.get_variable(name=cursor_name.name)
|
|
52
52
|
if cursor_expr.parent:
|
|
53
53
|
return cursor_expr.parent.args.get("cursor_args")
|
|
54
54
|
return []
|
|
@@ -101,8 +101,11 @@ def _resolve_call_sites(
|
|
|
101
101
|
Extract child statements and inline user-defined functions into downstream query holders.
|
|
102
102
|
"""
|
|
103
103
|
subst_statements: list[exp.Expr] = []
|
|
104
|
+
call_scope_pushed = False
|
|
104
105
|
if isinstance(query, CallQuery):
|
|
105
|
-
subst_statements = substitute.substitute_call(query=query)
|
|
106
|
+
subst_statements, bindings = substitute.substitute_call(query=query)
|
|
107
|
+
object_mapping.variables.push_scope(bindings)
|
|
108
|
+
call_scope_pushed = True
|
|
106
109
|
elif isinstance(query, DoQuery):
|
|
107
110
|
subst_statements = query.inner_statements
|
|
108
111
|
elif isinstance(query, ExecuteQuery):
|
|
@@ -120,9 +123,13 @@ def _resolve_call_sites(
|
|
|
120
123
|
process_statement(subst_stmt, dialect, object_mapping, stmt_index, parent_holder=holder)
|
|
121
124
|
|
|
122
125
|
parent_index = query.get_statement_index()
|
|
126
|
+
|
|
123
127
|
for i, stmt in enumerate(subst_statements):
|
|
124
128
|
process_statement(stmt, dialect, object_mapping, f"{parent_index}:{i}", parent_holder=holder)
|
|
125
129
|
|
|
130
|
+
if call_scope_pushed:
|
|
131
|
+
object_mapping.variables.pop_scope(write_back=True)
|
|
132
|
+
|
|
126
133
|
|
|
127
134
|
def _collect_sequential_children(
|
|
128
135
|
query: Q, holder: QueryHolder, dialect: str, object_mapping: mappings.ObjectMapping
|
|
@@ -133,7 +140,7 @@ def _collect_sequential_children(
|
|
|
133
140
|
to use their results (e.g. variables/state).
|
|
134
141
|
"""
|
|
135
142
|
if isinstance(query, (BlockQuery, ForInQuery, LoopQuery, WhileQuery)):
|
|
136
|
-
object_mapping.
|
|
143
|
+
object_mapping.variables.push_block()
|
|
137
144
|
|
|
138
145
|
if isinstance(query, BlockQuery):
|
|
139
146
|
statement_idx = 0
|
|
@@ -163,7 +170,7 @@ def _collect_sequential_children(
|
|
|
163
170
|
# Loop over the inner statements N times (where N = the loop count)
|
|
164
171
|
for loop_val in query.range_values():
|
|
165
172
|
val_expr = exp.Neg(this=exp.Literal.number(-loop_val)) if loop_val < 0 else exp.Literal.number(loop_val)
|
|
166
|
-
object_mapping.declare_variable(target_name, val_expr)
|
|
173
|
+
object_mapping.variables.declare_variable(target_name, val_expr)
|
|
167
174
|
|
|
168
175
|
for stmt in query.inner_statements:
|
|
169
176
|
stmt_copy = util.copy_expression(stmt)
|
|
@@ -191,7 +198,7 @@ def _collect_sequential_children(
|
|
|
191
198
|
process_statement(stmt, dialect, object_mapping, i + 1, parent_holder=holder)
|
|
192
199
|
|
|
193
200
|
if isinstance(query, (BlockQuery, ForInQuery, LoopQuery, WhileQuery)):
|
|
194
|
-
object_mapping.
|
|
201
|
+
object_mapping.variables.pop_block()
|
|
195
202
|
|
|
196
203
|
|
|
197
204
|
def _collect_structural_children(
|
|
@@ -31,8 +31,8 @@ from sqlleaf.models.node import (
|
|
|
31
31
|
VarNode,
|
|
32
32
|
WindowNode,
|
|
33
33
|
)
|
|
34
|
-
from sqlleaf.models.query import
|
|
35
|
-
from sqlleaf.typing import
|
|
34
|
+
from sqlleaf.models.query import TableQuery
|
|
35
|
+
from sqlleaf.typing import SqlObjectType
|
|
36
36
|
|
|
37
37
|
logger = logging.getLogger("sqlleaf")
|
|
38
38
|
|
|
@@ -495,7 +495,7 @@ class BaseGenerator:
|
|
|
495
495
|
def create_node_from_type(
|
|
496
496
|
self,
|
|
497
497
|
object_type: SqlObjectType,
|
|
498
|
-
expression:
|
|
498
|
+
expression: exp.Expr | exp.Expr,
|
|
499
499
|
column_name: str,
|
|
500
500
|
gen_ctx: GeneratorContext,
|
|
501
501
|
pos_ctx: PositionContext,
|
|
@@ -16,6 +16,7 @@ from sqlleaf.models.query import (
|
|
|
16
16
|
Q,
|
|
17
17
|
UserDefinedFunctionQuery,
|
|
18
18
|
)
|
|
19
|
+
from sqlleaf.processors.transformer.base import BaseQueryTransformer
|
|
19
20
|
from sqlleaf.processors.transformer.expressions import normalize_values, simplify_format
|
|
20
21
|
from sqlleaf.processors.transformer.expressions.row import transform_row_function_to_subquery
|
|
21
22
|
|
|
@@ -192,7 +193,7 @@ def substitute_cursor_parameters(
|
|
|
192
193
|
Result: `SELECT UPPER('abc') AS name`
|
|
193
194
|
"""
|
|
194
195
|
params = [FunctionParam(name=arg.this.name, type=arg.args.get("kind")) for arg in cursor_args]
|
|
195
|
-
params_from_variables = {param.name: object_mapping.get_variable(param.name, raise_on_missing=False) for param in params}
|
|
196
|
+
params_from_variables = {param.name: object_mapping.variables.get_variable(param.name, raise_on_missing=False) for param in params}
|
|
196
197
|
param_map, positional_map = _build_param_maps(args=call_args or [], params=params, params_from_variables=params_from_variables)
|
|
197
198
|
return substitute_parameters(cursor_query, None, param_map, positional_map)
|
|
198
199
|
|
|
@@ -321,7 +322,19 @@ def _replace_dot_reference(
|
|
|
321
322
|
node.set("this", exp.Paren(this=sub.copy()))
|
|
322
323
|
|
|
323
324
|
|
|
324
|
-
def
|
|
325
|
+
def _resolve_call_args(query: CallQuery) -> list[exp.Expr]:
|
|
326
|
+
"""Resolve CALL argument expressions while the caller's variables are visible."""
|
|
327
|
+
query_transformer = BaseQueryTransformer(query)
|
|
328
|
+
resolved_args = []
|
|
329
|
+
for arg in query.args:
|
|
330
|
+
arg_copy = arg.copy()
|
|
331
|
+
wrapper = exp.select(arg_copy)
|
|
332
|
+
query_transformer.replace_variables_in_expression(wrapper)
|
|
333
|
+
resolved_args.append(wrapper.expressions[0])
|
|
334
|
+
return resolved_args
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def substitute_call(query: CallQuery) -> tuple[list[exp.Expr], dict[str, mappings.ParamBinding]]:
|
|
325
338
|
"""
|
|
326
339
|
Substitutes a CALL statement's arguments into the statmenets inside its body and returns them.
|
|
327
340
|
Circular references in procedure-to-procedure calls could cause infinite recursion.
|
|
@@ -332,35 +345,48 @@ def substitute_call(query: CallQuery) -> list[exp.Expr]:
|
|
|
332
345
|
->
|
|
333
346
|
SELECT 3;
|
|
334
347
|
"""
|
|
335
|
-
|
|
348
|
+
resolved_args = _resolve_call_args(query)
|
|
349
|
+
matched_proc = query.object_mapping.lookup_procedure_call(query, args=resolved_args)
|
|
336
350
|
if not matched_proc:
|
|
337
|
-
return []
|
|
351
|
+
return [], {}
|
|
338
352
|
|
|
339
353
|
logger.debug(f"Substituting CALL query '{query.name}' with procedure body")
|
|
340
354
|
|
|
341
355
|
# Re-use find_arg logic. We don't have an Anonymous node,
|
|
342
356
|
# just a list of args from the CallQuery.
|
|
343
|
-
|
|
357
|
+
bindings = {}
|
|
344
358
|
positional_map = {}
|
|
345
|
-
args =
|
|
359
|
+
args = resolved_args
|
|
346
360
|
|
|
347
361
|
for i, param in enumerate(matched_proc.parameters):
|
|
348
|
-
arg_expr = _find_arg(args, param, i)
|
|
362
|
+
arg_expr = _find_arg(args, param, i)
|
|
363
|
+
raw_arg_expr = _find_arg(query.args, param, i)
|
|
364
|
+
|
|
365
|
+
if param.is_output:
|
|
366
|
+
initial_value = exp.Null()
|
|
367
|
+
if param.is_input and arg_expr is not None:
|
|
368
|
+
initial_value = arg_expr.copy()
|
|
369
|
+
arg_name = raw_arg_expr.name if isinstance(raw_arg_expr, exp.Column) and not raw_arg_expr.table else None
|
|
370
|
+
bindings[param.name.lower()] = mappings.ParamBinding(value=initial_value, arg_name=arg_name)
|
|
371
|
+
else:
|
|
372
|
+
value = arg_expr or param.default or exp.Null()
|
|
373
|
+
bindings[param.name.lower()] = mappings.ParamBinding(value=value.copy())
|
|
349
374
|
|
|
350
375
|
if arg_expr:
|
|
351
|
-
param_map[param.name.lower()] = arg_expr
|
|
352
376
|
positional_map[str(i + 1)] = arg_expr
|
|
377
|
+
elif param.default:
|
|
378
|
+
positional_map[str(i + 1)] = param.default
|
|
353
379
|
|
|
354
380
|
replacement_exprs = []
|
|
355
381
|
for stmt in matched_proc.inner_statements:
|
|
356
382
|
# Procedures can contain multiple statements
|
|
357
|
-
new_stmt = substitute_parameters(stmt.copy(), None,
|
|
383
|
+
new_stmt = substitute_parameters(stmt.copy(), None, {}, positional_map)
|
|
358
384
|
replacement_exprs.append(new_stmt)
|
|
359
385
|
|
|
360
386
|
logger.debug(f"Substituted to {len(replacement_exprs)} statements:")
|
|
361
387
|
for r in replacement_exprs:
|
|
362
388
|
logger.debug(f" {r.sql(dialect=query.dialect)}")
|
|
363
|
-
return replacement_exprs
|
|
389
|
+
return replacement_exprs, bindings
|
|
364
390
|
|
|
365
391
|
|
|
366
392
|
def substitute_execute_with_plan(
|
|
@@ -425,7 +451,7 @@ def resolve_dynamic_sql_command(
|
|
|
425
451
|
if isinstance(command, exp.Literal):
|
|
426
452
|
resolved_command = command
|
|
427
453
|
elif isinstance(command, exp.Column):
|
|
428
|
-
resolved_command = object_mapping.get_variable(name=command.name)
|
|
454
|
+
resolved_command = object_mapping.variables.get_variable(name=command.name)
|
|
429
455
|
if not isinstance(resolved_command, exp.Literal):
|
|
430
456
|
exception.raise_error(
|
|
431
457
|
exception.UnsupportedFeatureError,
|
|
@@ -438,7 +464,7 @@ def resolve_dynamic_sql_command(
|
|
|
438
464
|
for column in list(command_with_variables.find_all(exp.Column)):
|
|
439
465
|
if column.table:
|
|
440
466
|
continue
|
|
441
|
-
variable = object_mapping.get_variable(name=column.name, raise_on_missing=False)
|
|
467
|
+
variable = object_mapping.variables.get_variable(name=column.name, raise_on_missing=False)
|
|
442
468
|
if variable is not None:
|
|
443
469
|
column.replace(variable.copy())
|
|
444
470
|
formatted_command = simplify_format(command_with_variables, dialect=dialect)
|
|
@@ -453,7 +479,7 @@ def resolve_dynamic_sql_command(
|
|
|
453
479
|
|
|
454
480
|
resolved_stmt = sqlglot.parse_one(resolved_command.this, dialect=dialect)
|
|
455
481
|
if using:
|
|
456
|
-
resolved_using = object_mapping.get_variables_for(expressions=using)
|
|
482
|
+
resolved_using = object_mapping.variables.get_variables_for(expressions=using)
|
|
457
483
|
if resolved_using:
|
|
458
484
|
positional_map = {str(i + 1): value for i, value in enumerate(resolved_using)}
|
|
459
485
|
resolved_stmt = substitute_parameters(resolved_stmt, None, {}, positional_map)
|
|
@@ -55,7 +55,7 @@ class BaseQueryTransformer:
|
|
|
55
55
|
return BaseQueryTransformer(query)
|
|
56
56
|
return target_class(query)
|
|
57
57
|
|
|
58
|
-
def transform(self, statement: E) ->
|
|
58
|
+
def transform(self, statement: E) -> exp.Expr:
|
|
59
59
|
"""
|
|
60
60
|
Default transformation function that subclasses override to add query-type-specific logic.
|
|
61
61
|
"""
|
|
@@ -67,19 +67,20 @@ class BaseQueryTransformer:
|
|
|
67
67
|
"""
|
|
68
68
|
|
|
69
69
|
@functools.wraps(func)
|
|
70
|
-
def wrapper(self, *args, **kwargs) -> E:
|
|
70
|
+
def wrapper(self, *args, **kwargs) -> E | None:
|
|
71
71
|
statement = args[0] if args else kwargs.get("statement", self.query.statement)
|
|
72
72
|
query = self.query
|
|
73
|
+
in_statement = statement.sql(dialect=query.dialect)
|
|
73
74
|
|
|
74
75
|
if LOG_TRANSFORMATIONS:
|
|
75
76
|
logger.debug(f"Function: {func.__name__}")
|
|
76
77
|
|
|
77
78
|
result = func(self, *args, **kwargs)
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
out_statement =
|
|
80
|
+
result_statement = statement if result is None else result
|
|
81
|
+
out_statement = result_statement.sql(dialect=query.dialect)
|
|
81
82
|
|
|
82
|
-
if
|
|
83
|
+
if in_statement != out_statement:
|
|
83
84
|
logger.debug(f"Function: {func.__name__} transformed: {out_statement}")
|
|
84
85
|
|
|
85
86
|
return result
|
|
@@ -122,12 +123,12 @@ class BaseQueryTransformer:
|
|
|
122
123
|
|
|
123
124
|
validate_columns, exclusion_rules = self._get_validation_and_exclusion_rules(statement)
|
|
124
125
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
self._add_aliases_to_udfs(statement)
|
|
127
|
+
self._qualify_function_columns(statement)
|
|
128
|
+
self._apply_qualify(statement, validate_columns)
|
|
129
|
+
rewrite_functional_notation_columns(statement)
|
|
130
|
+
self._add_aliases_to_pseudocolumns(statement)
|
|
131
|
+
self._add_column_names_to_insert(statement)
|
|
131
132
|
statement = self._apply_optimizations(statement, exclusion_rules)
|
|
132
133
|
# statement = self._add_missing_table_alias_columns(statement)
|
|
133
134
|
|
|
@@ -186,17 +187,18 @@ class BaseQueryTransformer:
|
|
|
186
187
|
if table_name:
|
|
187
188
|
table_query = self.query.object_mapping.lookup_table_query(table=exp.to_table(table_name))
|
|
188
189
|
if not table_query:
|
|
189
|
-
variable = self.query.object_mapping.get_variable(table_name, raise_on_missing=False)
|
|
190
|
+
variable = self.query.object_mapping.variables.get_variable(table_name, raise_on_missing=False)
|
|
190
191
|
if variable is not None and isinstance(variable, exp.Query):
|
|
191
192
|
replacement = exp.Dot(this=_as_subquery(variable), expression=exp.to_identifier(column.name))
|
|
192
193
|
logger.debug(f"Replacing field access '{column.sql(self.query.dialect)}' with '{replacement.sql(self.query.dialect)}'")
|
|
193
194
|
column.replace(replacement)
|
|
194
195
|
continue
|
|
195
196
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
if not table_name:
|
|
198
|
+
variable = self.query.object_mapping.variables.get_variable(column.name, raise_on_missing=False)
|
|
199
|
+
if variable is not None:
|
|
200
|
+
logger.debug(f"Replacing column '{column.name}' with variable '{str(variable)}'")
|
|
201
|
+
column.replace(variable.copy())
|
|
200
202
|
|
|
201
203
|
def _expand_to_query(self, statement: E) -> None:
|
|
202
204
|
"""
|
|
@@ -245,7 +247,7 @@ class BaseQueryTransformer:
|
|
|
245
247
|
statement.set("expression", exp.select("*").from_(table))
|
|
246
248
|
|
|
247
249
|
@_validate_syntax
|
|
248
|
-
def _add_aliases_to_udfs(self, statement: E) ->
|
|
250
|
+
def _add_aliases_to_udfs(self, statement: E) -> None:
|
|
249
251
|
"""
|
|
250
252
|
Iterate over the query looking for UDFs and add an alias to them with the same name
|
|
251
253
|
as the UDF if it doesn't already exist. This prevents sqlglot from adding its own
|
|
@@ -278,10 +280,8 @@ class BaseQueryTransformer:
|
|
|
278
280
|
# Wrap the expression in an Alias
|
|
279
281
|
to_alias.replace(exp.alias_(to_alias.copy(), name))
|
|
280
282
|
|
|
281
|
-
return statement
|
|
282
|
-
|
|
283
283
|
@_validate_syntax
|
|
284
|
-
def _add_aliases_to_pseudocolumns(self, statement: E) ->
|
|
284
|
+
def _add_aliases_to_pseudocolumns(self, statement: E) -> None:
|
|
285
285
|
"""
|
|
286
286
|
Given a query:
|
|
287
287
|
SELECT xmax FROM fruit.raw
|
|
@@ -299,15 +299,13 @@ class BaseQueryTransformer:
|
|
|
299
299
|
from_table_alias = pseudo.parent_select.args["from_"].alias_or_name
|
|
300
300
|
pseudo.set("table", exp.to_identifier(from_table_alias))
|
|
301
301
|
|
|
302
|
-
return statement
|
|
303
|
-
|
|
304
302
|
@_validate_syntax
|
|
305
|
-
def _process_inner_ctes(self, statement: E) ->
|
|
303
|
+
def _process_inner_ctes(self, statement: E) -> None:
|
|
306
304
|
"""
|
|
307
305
|
Transform any inner CTE statements.
|
|
308
306
|
"""
|
|
309
307
|
if not isinstance(statement, (exp.Insert | exp.Merge | exp.Update | exp.Delete)):
|
|
310
|
-
return
|
|
308
|
+
return
|
|
311
309
|
|
|
312
310
|
for cte_expr in getattr(statement, "ctes", []):
|
|
313
311
|
if isinstance(cte_expr.this, exp.Update):
|
|
@@ -334,8 +332,6 @@ class BaseQueryTransformer:
|
|
|
334
332
|
# Rename the columns and replace the INSERT with the SELECT
|
|
335
333
|
self._rename_returning_columns(statement=cte_expr, child_table=cte_expr.find(exp.Table))
|
|
336
334
|
|
|
337
|
-
return statement
|
|
338
|
-
|
|
339
335
|
#@_validate_syntax
|
|
340
336
|
def _convert_insert_defaults_to_values(self, statement: exp.Insert) -> None:
|
|
341
337
|
"""
|
|
@@ -413,7 +409,7 @@ class BaseQueryTransformer:
|
|
|
413
409
|
return [r for r in RULES if getattr(r, "__name__", None) not in exclude_rules]
|
|
414
410
|
|
|
415
411
|
@_validate_syntax
|
|
416
|
-
def _qualify_function_columns(self, statement: E) ->
|
|
412
|
+
def _qualify_function_columns(self, statement: E) -> None:
|
|
417
413
|
"""
|
|
418
414
|
Look for table functions used in FROM whose names are known
|
|
419
415
|
and ensure they have a TableAlias with the correct default column list.
|
|
@@ -428,7 +424,7 @@ class BaseQueryTransformer:
|
|
|
428
424
|
"""
|
|
429
425
|
fn_columns_map: dict[str, list[str]] = get_system_functions(self.query.dialect)
|
|
430
426
|
if not fn_columns_map:
|
|
431
|
-
return
|
|
427
|
+
return
|
|
432
428
|
|
|
433
429
|
# Iterate over SELECT statements and inspect their FROM/JOIN clauses
|
|
434
430
|
for select in statement.find_all(exp.Select):
|
|
@@ -468,8 +464,6 @@ class BaseQueryTransformer:
|
|
|
468
464
|
elif not alias.columns:
|
|
469
465
|
alias.set("columns", [exp.to_identifier(c) for c in cols])
|
|
470
466
|
|
|
471
|
-
return statement
|
|
472
|
-
|
|
473
467
|
def _get_validation_and_exclusion_rules(self, statement: E) -> tuple[bool, list[str]]:
|
|
474
468
|
"""
|
|
475
469
|
Determine some settings used in the main transformer functions.
|
|
@@ -511,12 +505,12 @@ class BaseQueryTransformer:
|
|
|
511
505
|
statement = merge_derived_tables(statement)
|
|
512
506
|
|
|
513
507
|
# Add surrounding parens to some expressions (optimize() removes them)
|
|
514
|
-
|
|
508
|
+
add_parens_for_composite_field_access(statement)
|
|
515
509
|
|
|
516
510
|
return statement
|
|
517
511
|
|
|
518
512
|
@_validate_syntax
|
|
519
|
-
def _apply_qualify(self, statement: E, validate_columns: bool) ->
|
|
513
|
+
def _apply_qualify(self, statement: E, validate_columns: bool) -> None:
|
|
520
514
|
"""
|
|
521
515
|
Run sqlglot's qualify() function against the statement for schema validation and naming/aliasing population.
|
|
522
516
|
"""
|
|
@@ -528,10 +522,9 @@ class BaseQueryTransformer:
|
|
|
528
522
|
validate_qualify_columns=validate_columns,
|
|
529
523
|
quote_identifiers=False,
|
|
530
524
|
)
|
|
531
|
-
return statement
|
|
532
525
|
|
|
533
526
|
@_validate_syntax
|
|
534
|
-
def _add_missing_table_alias_columns(self, statement: E) ->
|
|
527
|
+
def _add_missing_table_alias_columns(self, statement: E) -> None:
|
|
535
528
|
"""
|
|
536
529
|
Populate any missing column lists on exp.TableAlias nodes by copying the
|
|
537
530
|
output column names from the aliased expression (typically a Subquery).
|
|
@@ -600,10 +593,8 @@ class BaseQueryTransformer:
|
|
|
600
593
|
new_cols = existing_cols + [exp.to_identifier(n) for n in missing]
|
|
601
594
|
tbl_alias.set("columns", new_cols)
|
|
602
595
|
|
|
603
|
-
return statement
|
|
604
|
-
|
|
605
596
|
@_validate_syntax
|
|
606
|
-
def _rename_returning_columns(self, statement: exp.CTE, child_table: exp.Table) ->
|
|
597
|
+
def _rename_returning_columns(self, statement: exp.CTE, child_table: exp.Table) -> None:
|
|
607
598
|
"""
|
|
608
599
|
Given an (INSERT .. RETURNING *) statement, expand the star to the table's column names
|
|
609
600
|
and add the correct column aliases.
|
|
@@ -625,7 +616,7 @@ class BaseQueryTransformer:
|
|
|
625
616
|
"""
|
|
626
617
|
returning_expr: exp.Returning = statement.this.args.get("returning", None)
|
|
627
618
|
if not returning_expr:
|
|
628
|
-
return
|
|
619
|
+
return
|
|
629
620
|
|
|
630
621
|
for col_expr in returning_expr.expressions:
|
|
631
622
|
if not isinstance(col_expr, (exp.Alias, exp.Column, exp.Star)):
|
|
@@ -654,7 +645,6 @@ class BaseQueryTransformer:
|
|
|
654
645
|
new_select = exp.select(*returning_expr.expressions).from_(child_table)
|
|
655
646
|
|
|
656
647
|
statement.set("this", new_select)
|
|
657
|
-
return statement
|
|
658
648
|
|
|
659
649
|
@staticmethod
|
|
660
650
|
def _extract_merge_context(statement: exp.Insert | exp.Update) -> dict | None:
|
|
@@ -691,7 +681,7 @@ class BaseQueryTransformer:
|
|
|
691
681
|
}
|
|
692
682
|
|
|
693
683
|
@_validate_syntax
|
|
694
|
-
def _add_column_names_to_insert(self, statement: exp.Expr) ->
|
|
684
|
+
def _add_column_names_to_insert(self, statement: exp.Expr) -> None:
|
|
695
685
|
"""
|
|
696
686
|
Add aliases to SELECTs that are missing them by looking at the corresponding INSERT column.
|
|
697
687
|
This prevents sqlglot from assigning its own generated names as aliases.
|
|
@@ -706,14 +696,14 @@ class BaseQueryTransformer:
|
|
|
706
696
|
"""
|
|
707
697
|
query = self.query
|
|
708
698
|
if not isinstance(statement, exp.Insert) or not statement.selects:
|
|
709
|
-
return
|
|
699
|
+
return
|
|
710
700
|
|
|
711
701
|
# sqlglot throws a parse error on named columns for Snowflake: INSERT INTO @"my_eXt_sTaGe" (NAME, AGE) SELECT ...
|
|
712
702
|
SKIP_COLUMN_RENAME_TYPES = SqlObjectType.type_has_no_column_defs(query.source_info.type, query.target_info.type)
|
|
713
703
|
if SKIP_COLUMN_RENAME_TYPES:
|
|
714
704
|
# The aliases and column names already exist from a previous transformation,
|
|
715
705
|
# or the target is not a table (e.g. S3 file, stage, stream)
|
|
716
|
-
return
|
|
706
|
+
return
|
|
717
707
|
|
|
718
708
|
child_table = query.get_target_as_table()
|
|
719
709
|
table_query = query.object_mapping.get_table_or_stage(child_table)
|
|
@@ -767,8 +757,6 @@ class BaseQueryTransformer:
|
|
|
767
757
|
# Overwrite the aliases because sqlglot may have added incorrect ones
|
|
768
758
|
select.selects[i] = select.selects[i].as_(ins)
|
|
769
759
|
|
|
770
|
-
return statement
|
|
771
|
-
|
|
772
760
|
def _extract_insert_columns(
|
|
773
761
|
self, statement: exp.Insert, target: exp.Table | exp.Schema, include_system: bool = False
|
|
774
762
|
) -> list[str]:
|
|
@@ -16,10 +16,11 @@ class CopyTransformer(BaseQueryTransformer):
|
|
|
16
16
|
QUERY = CopyQuery
|
|
17
17
|
|
|
18
18
|
def transform(self, statement: exp.Copy) -> exp.Copy:
|
|
19
|
-
|
|
19
|
+
self._replace_table_source_with_select(statement)
|
|
20
|
+
return statement
|
|
20
21
|
|
|
21
22
|
@BaseQueryTransformer._validate_syntax
|
|
22
|
-
def _replace_table_source_with_select(self, statement: exp.Copy) ->
|
|
23
|
+
def _replace_table_source_with_select(self, statement: exp.Copy) -> None:
|
|
23
24
|
"""
|
|
24
25
|
Replace a table source inside the COPY statement with a SELECT over that table.
|
|
25
26
|
The COPY statement itself is kept.
|
|
@@ -37,7 +38,7 @@ class CopyTransformer(BaseQueryTransformer):
|
|
|
37
38
|
raise exception.InvalidQueryError(f"Could not find any columns for expression: {query.target_info.expression}")
|
|
38
39
|
|
|
39
40
|
if query.source_info.type != SqlObjectType.TABLE:
|
|
40
|
-
return
|
|
41
|
+
return
|
|
41
42
|
|
|
42
43
|
if dialect in ["postgres", "redshift"] and not statement.args["kind"]:
|
|
43
44
|
# COPY X TO STDOUT/STDIN
|
|
@@ -69,4 +70,3 @@ class CopyTransformer(BaseQueryTransformer):
|
|
|
69
70
|
|
|
70
71
|
select = exp.select(*columns, dialect=dialect).from_(query.source_info.expression.copy())
|
|
71
72
|
source_slot.replace(select.subquery())
|
|
72
|
-
return statement
|
|
@@ -17,10 +17,10 @@ class CTASTransformer(BaseQueryTransformer):
|
|
|
17
17
|
# BaseQueryTransformer.normalize_all_values); statement.expression is already
|
|
18
18
|
# clean of any exp.Values nodes.
|
|
19
19
|
if statement.expression:
|
|
20
|
-
|
|
20
|
+
self._convert_substituted_table_to_select(statement)
|
|
21
21
|
return statement
|
|
22
22
|
|
|
23
|
-
def _convert_substituted_table_to_select(self, statement: exp.Create) ->
|
|
23
|
+
def _convert_substituted_table_to_select(self, statement: exp.Create) -> None:
|
|
24
24
|
"""
|
|
25
25
|
Convert "CREATE TABLE w AS TABLE x" to "CREATE TABLE w AS SELECT * FROM x".
|
|
26
26
|
|
|
@@ -38,4 +38,3 @@ class CTASTransformer(BaseQueryTransformer):
|
|
|
38
38
|
if self.query.dialect == "postgres" and isinstance(expr, exp.Alias):
|
|
39
39
|
if expr.this.name.upper() == "TABLE":
|
|
40
40
|
expr.replace(exp.select("*").from_(expr.alias))
|
|
41
|
-
return statement
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from sqlglot import exp
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
def rewrite_functional_notation_columns(statement: exp.Expr) ->
|
|
6
|
+
def rewrite_functional_notation_columns(statement: exp.Expr) -> None:
|
|
7
7
|
"""
|
|
8
8
|
Rewrite Postgres functional-notation column references from exp.TableColumn to exp.Column.
|
|
9
9
|
|
|
@@ -19,4 +19,3 @@ def rewrite_functional_notation_columns(statement: exp.Expr) -> exp.Expr:
|
|
|
19
19
|
new_col = exp.Column(this=anon.this, table=arg.this)
|
|
20
20
|
anon.replace(new_col)
|
|
21
21
|
|
|
22
|
-
return statement
|
|
@@ -9,7 +9,7 @@ from sqlleaf.models.query import Q, UserDefinedFunctionQuery
|
|
|
9
9
|
logger = logging.getLogger("sqlleaf")
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def add_parens_for_composite_field_access(statement: exp.Expr) ->
|
|
12
|
+
def add_parens_for_composite_field_access(statement: exp.Expr) -> None:
|
|
13
13
|
"""
|
|
14
14
|
Ensure parentheses surround composite field dereference on expressions used with dot notation.
|
|
15
15
|
|
|
@@ -20,7 +20,6 @@ def add_parens_for_composite_field_access(statement: exp.Expr) -> exp.Expr:
|
|
|
20
20
|
left = dot.this
|
|
21
21
|
if isinstance(left, exp.Cast) and util.is_row_function(left.this):
|
|
22
22
|
dot.set("this", exp.Paren(this=left.copy()))
|
|
23
|
-
return statement
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
def simplify_row_in_values(values_expr: exp.Values, dialect: str) -> None:
|
|
@@ -15,8 +15,8 @@ class InsertTransformer(BaseQueryTransformer):
|
|
|
15
15
|
def transform(self, statement: exp.Insert) -> exp.Insert:
|
|
16
16
|
statement = self._add_information_from_merge(statement)
|
|
17
17
|
statement = self._add_information_from_multitable_insert(statement)
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
self._process_inner_ctes(statement)
|
|
19
|
+
self._remove_on_conflict(statement)
|
|
20
20
|
|
|
21
21
|
return statement
|
|
22
22
|
|
|
@@ -26,13 +26,12 @@ class InsertTransformer(BaseQueryTransformer):
|
|
|
26
26
|
statement = annotate_types(statement, dialect=self.query.dialect, schema=self.query.object_mapping)
|
|
27
27
|
return super().postprocess(statement)
|
|
28
28
|
|
|
29
|
-
def _remove_on_conflict(self, statement: exp.Insert) ->
|
|
29
|
+
def _remove_on_conflict(self, statement: exp.Insert) -> None:
|
|
30
30
|
"""
|
|
31
31
|
Remove the 'ON CONFLICT ...' clause from the INSERT statement.
|
|
32
32
|
"""
|
|
33
33
|
if conflict := statement.args.get("conflict"):
|
|
34
34
|
conflict.pop()
|
|
35
|
-
return statement
|
|
36
35
|
|
|
37
36
|
@BaseQueryTransformer._validate_syntax
|
|
38
37
|
def _add_information_from_merge(self, statement: exp.Insert) -> exp.Insert:
|
|
@@ -25,7 +25,7 @@ class OpenTransformer(BaseQueryTransformer):
|
|
|
25
25
|
|
|
26
26
|
# Fetch the cursor's expression and attach it to this query
|
|
27
27
|
if not cursor_expr:
|
|
28
|
-
cursor_expr = self.query.object_mapping.get_variable(name=cursor_name.name)
|
|
28
|
+
cursor_expr = self.query.object_mapping.variables.get_variable(name=cursor_name.name)
|
|
29
29
|
cursor_expr = cursor_expr.copy()
|
|
30
30
|
statement.set("expression", cursor_expr)
|
|
31
31
|
|
|
@@ -49,7 +49,7 @@ class OpenTransformer(BaseQueryTransformer):
|
|
|
49
49
|
|
|
50
50
|
return super().preprocess(cursor_expr)
|
|
51
51
|
|
|
52
|
-
def transform(self, statement: exp.Expr) ->
|
|
52
|
+
def transform(self, statement: exp.Expr) -> exp.Expr:
|
|
53
53
|
return statement
|
|
54
54
|
|
|
55
55
|
def _substitute_cursor_parameters(self, statement: E, cursor_args: list[pgexp.PGCursorArg]) -> E:
|
|
@@ -48,9 +48,9 @@ def set_variables_in_scope(query: Q) -> None:
|
|
|
48
48
|
name = query.get_key()
|
|
49
49
|
value = query.get_value()
|
|
50
50
|
if query.is_declaration:
|
|
51
|
-
query.object_mapping.declare_variable(name=name, value=value)
|
|
51
|
+
query.object_mapping.variables.declare_variable(name=name, value=value)
|
|
52
52
|
else:
|
|
53
|
-
query.object_mapping.set_variable(name=name, value=value)
|
|
53
|
+
query.object_mapping.variables.set_variable(name=name, value=value)
|
|
54
54
|
|
|
55
55
|
elif isinstance(query, SelectQuery):
|
|
56
56
|
original_stmt = query.holder.original.statement
|
|
@@ -61,13 +61,13 @@ def set_variables_in_scope(query: Q) -> None:
|
|
|
61
61
|
# `FOR .. IN SELECT ..`
|
|
62
62
|
name = original_parent.this.name
|
|
63
63
|
value = query.statement
|
|
64
|
-
query.object_mapping.set_variable(name=name, value=value)
|
|
64
|
+
query.object_mapping.variables.set_variable(name=name, value=value)
|
|
65
65
|
|
|
66
66
|
elif isinstance(original_parent, pgexp.PGOpen) and original_parent.args.get("expression") == original_stmt:
|
|
67
67
|
# `OPEN .. FOR SELECT ..`
|
|
68
68
|
name = original_parent.this.name
|
|
69
69
|
value = query.statement
|
|
70
|
-
query.object_mapping.set_variable(name=name, value=value)
|
|
70
|
+
query.object_mapping.variables.set_variable(name=name, value=value)
|
|
71
71
|
|
|
72
72
|
elif parent_holder and isinstance(parent_holder.original, ExecuteDynamicQuery):
|
|
73
73
|
# `FOR .. IN EXECUTE 'SELECT ..'`
|
|
@@ -76,18 +76,18 @@ def set_variables_in_scope(query: Q) -> None:
|
|
|
76
76
|
for_in_stmt = grandparent_holder.transformed.statement
|
|
77
77
|
name = for_in_stmt.this.name
|
|
78
78
|
value = query.statement
|
|
79
|
-
query.object_mapping.set_variable(name=name, value=value)
|
|
79
|
+
query.object_mapping.variables.set_variable(name=name, value=value)
|
|
80
80
|
|
|
81
81
|
elif isinstance(query, FetchQuery):
|
|
82
82
|
# FETCH <source> INTO <target>;
|
|
83
83
|
# Look up the value for the key and write it to the new key.
|
|
84
84
|
# TODO: should we just substitute the query as the variable?
|
|
85
85
|
var_key: exp.Identifier = query.statement.this
|
|
86
|
-
var_val = query.object_mapping.get_variable(name=var_key.name)
|
|
86
|
+
var_val = query.object_mapping.variables.get_variable(name=var_key.name)
|
|
87
87
|
targets = query.statement.args["expressions"]
|
|
88
88
|
|
|
89
89
|
if len(targets) == 1:
|
|
90
|
-
query.object_mapping.set_variable(name=targets[0].name, value=var_val)
|
|
90
|
+
query.object_mapping.variables.set_variable(name=targets[0].name, value=var_val)
|
|
91
91
|
else:
|
|
92
92
|
source_columns = var_val.selects if isinstance(var_val, exp.Query) else []
|
|
93
93
|
for i, target in enumerate(targets):
|
|
@@ -98,10 +98,10 @@ def set_variables_in_scope(query: Q) -> None:
|
|
|
98
98
|
)
|
|
99
99
|
else:
|
|
100
100
|
value = var_val
|
|
101
|
-
query.object_mapping.set_variable(name=target.name, value=value)
|
|
101
|
+
query.object_mapping.variables.set_variable(name=target.name, value=value)
|
|
102
102
|
|
|
103
103
|
elif isinstance(query, OpenQuery):
|
|
104
|
-
query.object_mapping.set_variable(name=query.target().name, value=query.source())
|
|
104
|
+
query.object_mapping.variables.set_variable(name=query.target().name, value=query.source())
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
def _transform_query_instance(query: Q) -> Q:
|
|
@@ -19,10 +19,10 @@ class UpdateTransformer(BaseQueryTransformer):
|
|
|
19
19
|
if isinstance(statement, (exp.Insert, exp.Update)):
|
|
20
20
|
statement = self._add_information_from_merge(statement)
|
|
21
21
|
if isinstance(statement, exp.Update):
|
|
22
|
-
|
|
22
|
+
self._convert_update_defaults_to_values(statement)
|
|
23
23
|
statement = self._convert_update_to_insert(statement)
|
|
24
24
|
if isinstance(statement, (exp.Insert, exp.Merge, exp.Update, exp.Delete)):
|
|
25
|
-
|
|
25
|
+
self._process_inner_ctes(statement)
|
|
26
26
|
return statement
|
|
27
27
|
|
|
28
28
|
def _convert_on_conflict_to_update(self, statement: exp.OnConflict | exp.Update) -> exp.Update:
|
|
@@ -112,7 +112,7 @@ class UpdateTransformer(BaseQueryTransformer):
|
|
|
112
112
|
|
|
113
113
|
return update_expr
|
|
114
114
|
|
|
115
|
-
def _convert_update_defaults_to_values(self, statement: exp.Update) ->
|
|
115
|
+
def _convert_update_defaults_to_values(self, statement: exp.Update) -> None:
|
|
116
116
|
"""
|
|
117
117
|
Transform the query:
|
|
118
118
|
UPDATE x SET a = DEFAULT
|
|
@@ -124,7 +124,7 @@ class UpdateTransformer(BaseQueryTransformer):
|
|
|
124
124
|
child_table = query.get_target_as_table()
|
|
125
125
|
table_query = query.object_mapping.lookup_table_query(table=child_table)
|
|
126
126
|
if not table_query:
|
|
127
|
-
return
|
|
127
|
+
return
|
|
128
128
|
|
|
129
129
|
table_columns = table_query.get_column_defs()
|
|
130
130
|
|
|
@@ -140,7 +140,6 @@ class UpdateTransformer(BaseQueryTransformer):
|
|
|
140
140
|
table_columns=table_columns,
|
|
141
141
|
)
|
|
142
142
|
|
|
143
|
-
return statement
|
|
144
143
|
|
|
145
144
|
def _add_information_from_merge(self, statement: exp.Insert | exp.Update) -> exp.Insert | exp.Update:
|
|
146
145
|
"""
|
sqlleaf/typing.py
CHANGED
|
@@ -7,17 +7,6 @@ from sqlglot.optimizer import Scope
|
|
|
7
7
|
|
|
8
8
|
E = t.TypeVar("E", bound=exp.Expr)
|
|
9
9
|
|
|
10
|
-
"""
|
|
11
|
-
Represents a source and a target object of an SQL query.
|
|
12
|
-
|
|
13
|
-
For example,
|
|
14
|
-
INSERT INTO <target> SELECT * FROM <source>
|
|
15
|
-
COPY <target> FROM <source>
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
TargetExprType = exp.Table | exp.Literal | exp.Identifier | exp.Schema
|
|
19
|
-
SourceExprType = exp.Table | exp.Literal | exp.Identifier | exp.Select | exp.Schema | exp.Values
|
|
20
|
-
|
|
21
10
|
TableOrScopeType = exp.Table | Scope
|
|
22
11
|
|
|
23
12
|
|
|
@@ -65,14 +54,14 @@ class SqlObjectType(StrEnum):
|
|
|
65
54
|
|
|
66
55
|
@dataclass(frozen=True)
|
|
67
56
|
class SourceInfo:
|
|
68
|
-
expression:
|
|
57
|
+
expression: exp.Expr
|
|
69
58
|
type: SqlObjectType
|
|
70
59
|
expressions: list[exp.Expr] = field(default_factory=list)
|
|
71
60
|
|
|
72
61
|
|
|
73
62
|
@dataclass(frozen=True)
|
|
74
63
|
class TargetInfo:
|
|
75
|
-
expression:
|
|
64
|
+
expression: exp.Expr
|
|
76
65
|
type: SqlObjectType
|
|
77
66
|
expressions: list[exp.Expr] = field(default_factory=list)
|
|
78
67
|
|
sqlleaf/util/expression.py
CHANGED
|
@@ -6,7 +6,7 @@ from sqlglot.optimizer.qualify import qualify
|
|
|
6
6
|
|
|
7
7
|
from sqlleaf.dialects.plpgsql import pgexp
|
|
8
8
|
from sqlleaf import exception, mappings, util
|
|
9
|
-
from sqlleaf.typing import E
|
|
9
|
+
from sqlleaf.typing import E
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def unwrap_expression(expr: E) -> exp.Expr:
|
|
@@ -63,7 +63,7 @@ def calculate_function_name(expr: exp.Expr, dialect: str) -> str:
|
|
|
63
63
|
return name[:first_bracket] + name[last_bracket + 1 :]
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
def find_property(statement: exp.Create, child_object:
|
|
66
|
+
def find_property(statement: exp.Create, child_object: exp.Expr, dialect: str) -> str:
|
|
67
67
|
"""
|
|
68
68
|
Get the table/view's property (e.g. TEMPORARY, EXTERNAL, RECURSIVE)
|
|
69
69
|
"""
|
|
@@ -166,7 +166,7 @@ def get_function_args(expr: exp.Func) -> list[exp.Expr]:
|
|
|
166
166
|
return result
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
def rename_if_stage(source:
|
|
169
|
+
def rename_if_stage(source: exp.Expr, target: exp.Expr) -> None:
|
|
170
170
|
"""
|
|
171
171
|
Normalize (uppercase) the name if we are a Snowflake stage.
|
|
172
172
|
sqlglot only normalizes columns - see comments in `sqlglot.optimizer.normalize_identifiers()`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
sqlleaf/__init__.py,sha256=HY_CDcGtsDRa-Fns6N7OhkklPhpM_XTUyrvMlrgW1hk,368
|
|
2
2
|
sqlleaf/exception.py,sha256=CyeSwbHe5sRXbPfbnFBi_IBBiPkqN9DvMqq6z8tkHzw,1250
|
|
3
3
|
sqlleaf/lineage.py,sha256=GWqCIV0NwtP0kpVucFcFYD9ivCi6GdpkPpuZmcPx71w,10201
|
|
4
|
-
sqlleaf/mappings.py,sha256=
|
|
4
|
+
sqlleaf/mappings.py,sha256=zy2Wj2S5ObATdsxtsNthpZS7Z-EVkNOEOMnA92ySBRQ,25345
|
|
5
5
|
sqlleaf/path.py,sha256=yqjgOn88dZ-BO2XwF5MDMhss51GJijSMBDsSeKk-0bo,6443
|
|
6
|
-
sqlleaf/typing.py,sha256=
|
|
6
|
+
sqlleaf/typing.py,sha256=jjrtGn_3y1zfwtLCP3Q6TIunQmiKSb3axGj5OXRjR44,1891
|
|
7
7
|
sqlleaf/dialects/__init__.py,sha256=1fvnsumjFeRdBVYk7hUgO4ohE2sXjF0zn955HC-wepw,55
|
|
8
8
|
sqlleaf/dialects/plpgsql/__init__.py,sha256=tNm6DUseMyYKOmHX8IJa0ZW4-JlJrbJCYc1mLH5-Jyo,56
|
|
9
9
|
sqlleaf/dialects/plpgsql/p_classes.py,sha256=JO3-l23qBa-zdjgciV4W5p48lYqGEX0vLZqOWpIFjr0,6027
|
|
@@ -33,11 +33,11 @@ sqlleaf/models/node/var.py,sha256=6kFy0bD10Db3X4XAW6mIdQoDyJDiN49gKCuttOTkpEs,13
|
|
|
33
33
|
sqlleaf/models/node/variable.py,sha256=DQ4Jvz6iieoB-m_BHURTJuEycGYLDi-Xa7mfRhOytGg,169
|
|
34
34
|
sqlleaf/models/node/window.py,sha256=Zs8eEmgM_kp2nrCy7rWNTittQg-7of0R0_EdDloAUOw,585
|
|
35
35
|
sqlleaf/models/query/__init__.py,sha256=P0TXSbtTS0Mg0lS_aiKDr-TxmSzzOVG-k35eeHjSbRs,3752
|
|
36
|
-
sqlleaf/models/query/base.py,sha256=
|
|
36
|
+
sqlleaf/models/query/base.py,sha256=bAh9RTefg_St6KfjRwRkWqf83P_zsTwhqQxtI7O8T6A,10207
|
|
37
37
|
sqlleaf/models/query/block.py,sha256=5muAjMC3a2tGEb2Bzn5YbSFSMYorbPz_DrzKAPqOH1w,992
|
|
38
38
|
sqlleaf/models/query/call.py,sha256=7wfXmDvp1terCStRd9U5YMQEePPEbS-AAbVA6dPcLWM,3233
|
|
39
39
|
sqlleaf/models/query/case.py,sha256=nVcB9oTsC3vGZKw-V_U9fBnEo1ItV4emsFCnekLW9Jo,856
|
|
40
|
-
sqlleaf/models/query/copy.py,sha256=
|
|
40
|
+
sqlleaf/models/query/copy.py,sha256=UUumeiH-0VXFhKmMrG8HqTxLDTLLjqxew5NUYzNsDsw,5078
|
|
41
41
|
sqlleaf/models/query/ctas.py,sha256=ju0r3duRg-oGt8IOIHBtzsQ9ScL0lHacTIpSHq-iGJo,1884
|
|
42
42
|
sqlleaf/models/query/database.py,sha256=g6OSYc_AKvmt-wSUKcWCn9KoJsAmjgPlO5vcZTIYGsk,1229
|
|
43
43
|
sqlleaf/models/query/declare_item.py,sha256=pHUv8T5iOVf_4SPO2GeSObpar-RhUTDvOdeCYLgeDiI,1005
|
|
@@ -54,7 +54,7 @@ sqlleaf/models/query/insert.py,sha256=zYdEyfuRjmqFQ9p4bqDNp_0ppaejbFE_NZ401G3O4R
|
|
|
54
54
|
sqlleaf/models/query/loop.py,sha256=u55dnJh0qRduzYX5e-WoOI71uFQK1LQrsTt0KlA-rJ8,738
|
|
55
55
|
sqlleaf/models/query/merge.py,sha256=d-Zasi677TuQeHwYq4qtyMUnuRZks_ZuAFfPX8-GM0c,820
|
|
56
56
|
sqlleaf/models/query/multitable_insert.py,sha256=KADLiKSV3LzWXjANG4or2WMSsyyy0akH3N71VvDQqMM,1311
|
|
57
|
-
sqlleaf/models/query/open.py,sha256=
|
|
57
|
+
sqlleaf/models/query/open.py,sha256=DhAqseQ03w4ZzlLy_mHVD7RkC0o-3QCLNgL1wFGgifs,1454
|
|
58
58
|
sqlleaf/models/query/perform.py,sha256=LIXB9gyNRj4jJ3JWnXQbK25g2oINTqlMOZQs1voK8oA,457
|
|
59
59
|
sqlleaf/models/query/prepare.py,sha256=tEgLYVHdBUBEebvUtYj7abI146OLHHTHAIHhntPPMN4,2548
|
|
60
60
|
sqlleaf/models/query/procedure.py,sha256=v5THnfEigzHF5iaUnHH_26jhk1VD8MsCrFy9qRG3tPA,3629
|
|
@@ -77,55 +77,55 @@ sqlleaf/models/query/while_.py,sha256=OT2UAtznjKSTjaOVAmYOf4V1_do0S7cMaTmJ0DCWWj
|
|
|
77
77
|
sqlleaf/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
78
78
|
sqlleaf/processors/collector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
79
79
|
sqlleaf/processors/collector/classify.py,sha256=1SSCdpE7s7pZczxJHZoXbUW51kdXeAodykf83ViHbhk,4442
|
|
80
|
-
sqlleaf/processors/collector/collector.py,sha256=
|
|
80
|
+
sqlleaf/processors/collector/collector.py,sha256=dmxop7uPra-6kUT4OeqIAH7uihzQ3uzBnQfQAS-DEzg,30397
|
|
81
81
|
sqlleaf/processors/generator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
82
82
|
sqlleaf/processors/generator/generator.py,sha256=Mkb2b3gMiQJ6GMMMMLSm4_9sLyhIkGo7CtOTEgM3UaY,22940
|
|
83
83
|
sqlleaf/processors/generator/dialects/__init__.py,sha256=D_odD7gs7EvS00eTX7JInqqgKRKyxWi_hKAfs1C4Vl0,478
|
|
84
84
|
sqlleaf/processors/generator/dialects/athena.py,sha256=lkzVb0wUvvyg-Dnq8rvcgu0zxpN_daYF4IxJnEWWcUA,1457
|
|
85
|
-
sqlleaf/processors/generator/dialects/base.py,sha256=
|
|
85
|
+
sqlleaf/processors/generator/dialects/base.py,sha256=3h_HKHeZrdaJYiwp2ZjoIvrJJkWPituq_a59esZUaCE,24980
|
|
86
86
|
sqlleaf/processors/generator/dialects/mysql.py,sha256=Bqzr3GAUbX1C6gex4HshVB2e8NbJuj3YDtyRbA1KYVA,588
|
|
87
87
|
sqlleaf/processors/generator/dialects/postgres.py,sha256=fy7A6CpX6uM85Ef4CBIiEaG6n1DiYAeKdvIRQbEYxSI,7334
|
|
88
88
|
sqlleaf/processors/generator/dialects/redshift.py,sha256=WSkr4_r3kek5HNIM_xmSjTKn-GqKRTsIftcmlgS16Oc,7400
|
|
89
89
|
sqlleaf/processors/generator/dialects/snowflake.py,sha256=8y4MgE99-iaUDlnvl4HhmNPGBU8UfUxsZr1qVuVSdq0,3158
|
|
90
90
|
sqlleaf/processors/substitutor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
91
|
-
sqlleaf/processors/substitutor/substitute.py,sha256=
|
|
91
|
+
sqlleaf/processors/substitutor/substitute.py,sha256=mJkbXbwm1gBLTsKEIU0y8u_TgmHCGU6-FF5QFm8J1Ww,30391
|
|
92
92
|
sqlleaf/processors/transformer/__init__.py,sha256=RX_a_WN2gAk5ZaKCmzPB-JdFEzyCV6tmvYsyRjl9Ujk,1828
|
|
93
93
|
sqlleaf/processors/transformer/assignment.py,sha256=nFAxpOsqCxLaBJz_xNsNxUFkDzr5Br3Nv0LAKJVsWj0,566
|
|
94
|
-
sqlleaf/processors/transformer/base.py,sha256=
|
|
94
|
+
sqlleaf/processors/transformer/base.py,sha256=EqL85VmwXJyNW1EuKPjcPVO4EugKh6UrU-UrFx5sf0A,38176
|
|
95
95
|
sqlleaf/processors/transformer/call.py,sha256=sjIPat9aoE6o2CrwAVTQ5vvuo6JmPeqiu--B1YlmGXA,220
|
|
96
96
|
sqlleaf/processors/transformer/case.py,sha256=udai6mPE6QQZ7Zm52YuZtnWo8EdA3_aCJYw0mFq7Nkc,264
|
|
97
|
-
sqlleaf/processors/transformer/copy.py,sha256=
|
|
98
|
-
sqlleaf/processors/transformer/ctas.py,sha256=
|
|
99
|
-
sqlleaf/processors/transformer/delete.py,sha256=
|
|
97
|
+
sqlleaf/processors/transformer/copy.py,sha256=rVX5VYc73Gbd85Odd9L_3KsmMQc_T0xRDtTRRKjzTj0,2560
|
|
98
|
+
sqlleaf/processors/transformer/ctas.py,sha256=Q3d6ZZZ-qXJ9wCSmkuSzQDy2x8w-Si1Kbi3PrWYyW2g,1625
|
|
99
|
+
sqlleaf/processors/transformer/delete.py,sha256=8M7Zsi7BwLqjG1U7IZcUkF7aimCfysPYeDQeYPKHERU,462
|
|
100
100
|
sqlleaf/processors/transformer/execute.py,sha256=8RYa0hWk1GfrasTQ4-MeCIjYfcvuPYeG-vfyUa1Vm-E,229
|
|
101
101
|
sqlleaf/processors/transformer/execute_dynamic.py,sha256=3RSbCksPfzkQ87HNNkAWBvpCZAn6hCOtfr_JwrxvwJ8,250
|
|
102
|
-
sqlleaf/processors/transformer/for_in.py,sha256=
|
|
103
|
-
sqlleaf/processors/transformer/insert.py,sha256=
|
|
104
|
-
sqlleaf/processors/transformer/merge.py,sha256=
|
|
102
|
+
sqlleaf/processors/transformer/for_in.py,sha256=1bNjjKJa9psN_S_YBRX3foLE2EwuD70ItJqVniYnVFg,899
|
|
103
|
+
sqlleaf/processors/transformer/insert.py,sha256=t7IF2Y-4J0TeJgij0RB3aToePaT__KaXErkSEdlzZCg,4654
|
|
104
|
+
sqlleaf/processors/transformer/merge.py,sha256=VXmfUFOhsfAQ747CHga5dlSt2LDO2QV9sqr6u61YWPc,454
|
|
105
105
|
sqlleaf/processors/transformer/multitable_insert.py,sha256=HktYEFQgxZB6jpw4b9CnIr93PFwvfMTd9GeAAWty3_8,502
|
|
106
|
-
sqlleaf/processors/transformer/open.py,sha256=
|
|
106
|
+
sqlleaf/processors/transformer/open.py,sha256=Ff_Ol6TJhsxbtA-qOMVCRvd4oDSQN3ezvHoHnadNgAk,3037
|
|
107
107
|
sqlleaf/processors/transformer/prepare.py,sha256=T8NGZLRsmO6ihN8pHXp4C517eqlxy-2M3pvSEb73SOM,646
|
|
108
108
|
sqlleaf/processors/transformer/replace.py,sha256=5Gu_RxjsyqUughukkZ4x0TswlvAMVHU56f9wQpoBtGE,1031
|
|
109
|
-
sqlleaf/processors/transformer/transformer.py,sha256=
|
|
110
|
-
sqlleaf/processors/transformer/unload.py,sha256=
|
|
111
|
-
sqlleaf/processors/transformer/update.py,sha256=
|
|
109
|
+
sqlleaf/processors/transformer/transformer.py,sha256=kn6QsQ0otNbCtCkV0AjCrKqgeYYOvwuyhuaVlyBer8c,7202
|
|
110
|
+
sqlleaf/processors/transformer/unload.py,sha256=nzDFL8Kr-XJ6ZQDKRbwbivqbDL2YKd8Giu0iJIiHae0,420
|
|
111
|
+
sqlleaf/processors/transformer/update.py,sha256=tlZw5gJJXKuaMM04OuFVP59Y5rIreuzcuEVJ5_lcGys,7939
|
|
112
112
|
sqlleaf/processors/transformer/values.py,sha256=JmNMeAcp1ntZOe4XaxPsIA6KRXlLme6WsgpztpmSsAg,300
|
|
113
113
|
sqlleaf/processors/transformer/expressions/__init__.py,sha256=bfdPhKeT4F8dX1KvQaiCETZtEU1yscXNzsDnUfY2ZdA,666
|
|
114
114
|
sqlleaf/processors/transformer/expressions/format.py,sha256=w-GH5H0-efoDI5w9S_ABKSQDtQz0PObCrVHDOYcj-eQ,9172
|
|
115
|
-
sqlleaf/processors/transformer/expressions/functional_notation.py,sha256=
|
|
116
|
-
sqlleaf/processors/transformer/expressions/row.py,sha256=
|
|
115
|
+
sqlleaf/processors/transformer/expressions/functional_notation.py,sha256=QV3ZogQ8tiWgpy16qnuVjulZUJVMSt7oN5kWsSctHaI,784
|
|
116
|
+
sqlleaf/processors/transformer/expressions/row.py,sha256=4IgtDcZH9gPDa5cX6idccXDxX7rQsCNGYFupyyBtkBY,16550
|
|
117
117
|
sqlleaf/processors/transformer/expressions/values.py,sha256=Ki4xbjUB7pCyAui7LoSw03zVHfP33sVycKQy_ICBiFk,12684
|
|
118
118
|
sqlleaf/settings/__init__.py,sha256=5v3fIGUrzr-5rBoGODyUr5xit9-FdQ92xw7GJjWaqBE,651
|
|
119
119
|
sqlleaf/settings/athena.py,sha256=YimVigDNwVoJ1EchBx1prYbJ9apSsW_axh0hebJljes,614
|
|
120
120
|
sqlleaf/settings/base.py,sha256=k-hMXsPwJDrTz_uIQj0xLkd30mmo-TVwB3PG2dCnNhM,979
|
|
121
121
|
sqlleaf/settings/postgres.py,sha256=cTQ9MAtVzjM2KqrlqdxkIbGDenbrsL79_caaEnIYzwo,1743
|
|
122
122
|
sqlleaf/util/__init__.py,sha256=timnzGikJKBbOTuQXTLS-pjKon50lUDF2E5sEaFUlRg,1359
|
|
123
|
-
sqlleaf/util/expression.py,sha256=
|
|
123
|
+
sqlleaf/util/expression.py,sha256=6yWl7V7_HGrM496wDv90GIfrbi-Vp2VRixQPvKBGcsc,10023
|
|
124
124
|
sqlleaf/util/graph.py,sha256=GyU4W8Yu47LFj6kUiH3y-mR4SERDNIjhPfYghbkDFzg,3646
|
|
125
125
|
sqlleaf/util/helpers.py,sha256=YCb2g6HBgI9GY-LySdKXAYADow2X-nj8jE8IbMMSxD4,914
|
|
126
126
|
sqlleaf/util/iterators.py,sha256=NLhn3LeGx23ZSdqwW5QZ216jhZm7HtSP9cswB-Ie3wQ,1376
|
|
127
|
-
sqlleaf-0.0.
|
|
128
|
-
sqlleaf-0.0.
|
|
129
|
-
sqlleaf-0.0.
|
|
130
|
-
sqlleaf-0.0.
|
|
131
|
-
sqlleaf-0.0.
|
|
127
|
+
sqlleaf-0.0.5.dist-info/licenses/LICENSE,sha256=z6iHh46VCvulJEPA9ZyH9v31vKaln0ZbwiUNicP6d1U,1071
|
|
128
|
+
sqlleaf-0.0.5.dist-info/METADATA,sha256=t2nBYi1SDHWYckmY7eT4VSbr3nMtYqvHZJa_ekoMV2w,7645
|
|
129
|
+
sqlleaf-0.0.5.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
130
|
+
sqlleaf-0.0.5.dist-info/top_level.txt,sha256=dokK2cq3jbXlILUgh6ymk5kGkJj7FqvTSBLGEzSRpjQ,8
|
|
131
|
+
sqlleaf-0.0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|