-
Hi, I would like to extract the number of joins in a list of query strings. Explicit joins can be found by findall(exp.Joins). But I think there could be overlaps if explicit joins have ON conditions. I am wonder if there is any smiple way to count all the joins. Or there could be any reference code from the sqlglot's Optimizor Module I did not find. My current idea is like: I am wondering if this is correct or if there exists any simpler idea. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
By "implicit joins", I'm assuming you mean this: SELECT
*
FROM x, y If you're just trying to count the number of joined tables: expression = parse_one("SELECT ...")
implicit_joins = set()
for from_ in expression.find_all(exp.From):
implicit_joins.update(from_.expressions[1:]) |
Beta Was this translation helpful? Give feedback.
By "implicit joins", I'm assuming you mean this:
If you're just trying to count the number of joined tables: