summaryrefslogtreecommitdiffstats
path: root/sqlglot/optimizer/optimize_joins.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlglot/optimizer/optimize_joins.py')
-rw-r--r--sqlglot/optimizer/optimize_joins.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/sqlglot/optimizer/optimize_joins.py b/sqlglot/optimizer/optimize_joins.py
index fd69832..dc5ce44 100644
--- a/sqlglot/optimizer/optimize_joins.py
+++ b/sqlglot/optimizer/optimize_joins.py
@@ -6,6 +6,11 @@ from sqlglot.optimizer.simplify import simplify
def optimize_joins(expression):
"""
Removes cross joins if possible and reorder joins based on predicate dependencies.
+
+ Example:
+ >>> from sqlglot import parse_one
+ >>> optimize_joins(parse_one("SELECT * FROM x CROSS JOIN y JOIN z ON x.a = z.a AND y.a = z.a")).sql()
+ 'SELECT * FROM x JOIN z ON x.a = z.a AND TRUE JOIN y ON y.a = z.a'
"""
for select in expression.find_all(exp.Select):
references = {}