MCPcopy Index your code
hub / github.com/tobymao/sqlglot / test_cte

Method test_cte

tests/test_diff.py:153–176  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

151 )
152
153 def test_cte(self):
154 expr_src = """
155 WITH
156 cte1 AS (SELECT a, b, LOWER(c) AS c FROM table_one WHERE d = 'filter'),
157 cte2 AS (SELECT d, e, f FROM table_two)
158 SELECT a, b, d, e FROM cte1 JOIN cte2 ON f = c
159 """
160 expr_tgt = """
161 WITH
162 cte1 AS (SELECT a, b, c FROM table_one WHERE d = 'different_filter'),
163 cte2 AS (SELECT d, e, f FROM table_two)
164 SELECT a, b, d, e FROM cte1 JOIN cte2 ON f = c
165 """
166
167 self._validate_delta_only(
168 diff_delta_only(parse_one(expr_src), parse_one(expr_tgt)),
169 [
170 Remove(expression=parse_one("LOWER(c) AS c")), # the Alias node
171 Remove(expression=parse_one("LOWER(c)")), # the Lower node
172 Remove(expression=parse_one("'filter'")), # the Literal node
173 Insert(expression=parse_one("'different_filter'")), # the Literal node
174 Move(source=parse_one("c"), target=parse_one("c")), # the new Column c
175 ],
176 )
177
178 def test_join(self):
179 expr_src = parse_one("SELECT a, b FROM t1 LEFT JOIN t2 ON t1.key = t2.key")

Callers

nothing calls this directly

Calls 6

_validate_delta_onlyMethod · 0.95
parse_oneFunction · 0.90
RemoveClass · 0.90
InsertClass · 0.90
MoveClass · 0.90
diff_delta_onlyFunction · 0.85

Tested by

no test coverage detected