Skip to content
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

Merged
merged 10 commits into from
Feb 16, 2025
Merged

Improve SQL Planner docs #14669

merged 10 commits into from
Feb 16, 2025

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Feb 14, 2025

Which issue does this PR close?

Rationale for this change

I have been listening to CMU's A Journey Through Database Query Optimization

Screenshot 2025-02-14 at 10 52 54 AM

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 entites

Are these changes tested?

By docs CI

Are there any user-facing changes?

@alamb alamb marked this pull request as ready for review February 14, 2025 15:51
@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions core Core DataFusion crate labels Feb 14, 2025
//! [`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").
Copy link
Contributor Author

@alamb alamb Feb 14, 2025

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

@xudong963 xudong963 self-requested a review February 14, 2025 16:48
Copy link
Member

@jonahgao jonahgao left a 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

@@ -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`].
Copy link
Member

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.

/// CTE stands for "Common Table Expression"
///
/// # Notes
/// We don't directly implement this in ['SqlToRel`] as implementing this function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph is not well formatted.

CleanShot 2025-02-15 at 22 07 48@2x

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 54fac30

Uploading Screenshot 2025-02-16 at 6.44.37 AM.png…

/// 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
Copy link
Member

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.

Copy link
Contributor Author

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.

@alamb alamb added the documentation Improvements or additions to documentation label Feb 16, 2025
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Feb 16, 2025
@comphead comphead merged commit 6d517fd into apache:main Feb 16, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants