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

Method test_join

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

Source from the content-addressed store, hash-verified

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")
180 expr_tgt = parse_one("SELECT a, b FROM t1 RIGHT JOIN t2 ON t1.key = t2.key")
181
182 src_join = expr_src.find(exp.Join)
183 tgt_join = expr_tgt.find(exp.Join)
184
185 self._validate_delta_only(
186 diff_delta_only(expr_src, expr_tgt),
187 [
188 Remove(expression=src_join),
189 Insert(expression=tgt_join),
190 Move(source=exp.to_table("t2"), target=exp.to_table("t2")),
191 Move(source=src_join.args["on"], target=tgt_join.args["on"]),
192 ],
193 )
194
195 expr_src = parse_one("SELECT a.x FROM a INNER JOIN b ON a.x = b.y LEFT JOIN c ON a.p = c.q")
196 expr_tgt = parse_one("SELECT a.x FROM a inner JOIN b ON a.x = b.y left JOIN c ON a.p = c.q")
197
198 self._validate_delta_only(diff_delta_only(expr_src, expr_tgt), [])
199
200 def test_window_functions(self):
201 expr_src = parse_one("SELECT ROW_NUMBER() OVER (PARTITION BY a ORDER BY b)")

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected