You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add example for writing an SQL analysis pass #10871
However, we don't have anexample for writing some sort of SQL analysis -- for example what @LorrensP-2158466 mentions about finding cyclic joins in #10808 (comment).
However, I know of several users of DataFusion doing this (e.g. @sadboy and SDF)
Perhaps the example could show how to create LogicalPlans for several sql query texts, and then use DataFusion structures to do an analysis (like maybe join counts, or predicate analysis or something) would be really neat.
I like the Join count analysis, I had to do this in my project (mentioned in #10808) in a really hacky way. We can have 2 sorts of counts:
Count every individual join
Count all groups of joins (subsequent joins that are related) with their respective count(this would have been useful for me)
I do have a question.
How can we show these results? Because Analyzer rules only return transformed LogicalPlans, or do I understand something in a wrong way?
Thank you @LorrensP-2158466 -- sorry for the delay . I have been traveling
I do have a question.
How can we show these results? Because Analyzer rules only return transformed LogicalPlans, or do I understand something in a wrong way?
I think in an example, we can use println! which is what we do in other examples:
Activity
LorrensP-2158466 commentedon Jun 11, 2024
I like the Join count analysis, I had to do this in my project (mentioned in #10808) in a really hacky way. We can have 2 sorts of counts:
I do have a question.
How can we show these results? Because Analyzer rules only return transformed LogicalPlans, or do I understand something in a wrong way?
alamb commentedon Jun 15, 2024
Thank you @LorrensP-2158466 -- sorry for the delay . I have been traveling
I think in an example, we can use
println!which is what we do in other examples:datafusion/datafusion-examples/examples/rewrite_expr.rs
Lines 45 to 48 in 3773fb7
Normally the idea is to give a well documented example that shows the basic pattern that people can start with
For this one, maybe you could show how to use
TreeNode::applyto walk the tree. Something like (totally untested)LorrensP-2158466 commentedon Jun 15, 2024
Thanks for the reply!
That's exactly what I have made, I'll open up a PR later today or tomorrow.