-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve SQL Planner docs #14669
Improve SQL Planner docs #14669
Conversation
//! [`SqlToRel`] planner. | ||
//! 2. The AST is converted to a [`LogicalPlan`] and logical expressions | ||
//! [`Expr`]s to compute the desired result by [`SqlToRel`]. This phase | ||
//! also includes name and type resolution ("binding"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly wanted the term "binding" to appear here, but then I got carried away when I explored a bit more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @alamb for improving these docs
datafusion/core/src/lib.rs
Outdated
@@ -185,7 +185,7 @@ | |||
//! specialize any behavior for your use case. For example, | |||
//! some projects may add custom [`ExecutionPlan`] operators, or create their own | |||
//! query language that directly creates [`LogicalPlan`] rather than using the | |||
//! built in SQL planner, [`SqlToRel`]. | |||
//! provided in SQL planner, [`SqlToRel`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“builtin” is clearer to me.
datafusion/expr/src/planner.rs
Outdated
/// CTE stands for "Common Table Expression" | ||
/// | ||
/// # Notes | ||
/// We don't directly implement this in ['SqlToRel`] as implementing this function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 54fac30
datafusion/sql/src/planner.rs
Outdated
/// phase looks up table and column names using the [`ContextProvider`]. | ||
/// 2. Mechanical translation of the AST into a [`LogicalPlan`]. | ||
/// | ||
/// It does not perform type checking, semantic analysis, type coercion, or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if check_unnest_arg conflicts with the description of type checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point that some non trivial amount of semantic analysis and checking is done in the planner. I removed this text to make it:
/// It does not perform type coercion, or perform optimization, which are done
/// by subsequent passes.
Co-authored-by: Jonah Gao <[email protected]>
Which issue does this PR close?
Rationale for this change
I have been listening to CMU's A Journey Through Database Query Optimization
which has inspired me to improve the documentation on our planner. (🙌 @lmwnshn)
Specifically the term "Binder" comes up a bunch in those lectures which I wasn't familiar with (I have always heard this concept referred to as variable and type resolution). Anyhow I wanted to make sure "binding" appeared in our docs and I saw the somewhat sparse docs and got carried away
What changes are included in this PR?
Improve the docs for
SqlToRel
and related entitesAre these changes tested?
By docs CI
Are there any user-facing changes?