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

Minor: Improve documentation in sql_to_plan example #10582

Merged
merged 1 commit into from
May 22, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented May 20, 2024

Which issue does this PR close?

Follow on to #10558 from @xinlifoobar (🙏 ) and @edmondop

Rationale for this change

I noticed a few potential improvements to the sql_to_plan examples

What changes are included in this PR?

  1. Improve the documentation and function names to make the examples better in my opinion

Are these changes tested?

Existing CI

Are there any user-facing changes?

@alamb alamb marked this pull request as ready for review May 20, 2024 17:47
Ok(())
}

/// DataFusion can convert expressions to SQL, using column name escaping
/// PostgreSQL style.
fn simple_expr_to_sql_demo() -> Result<()> {
let expr = col("a").lt(lit(5)).or(col("a").eq(lit(8)));
let ast = expr_to_sql(&expr)?;
let sql = format!("{}", ast);
let sql = expr_to_sql(&expr)?.to_string();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it makes it easier to use this example if we don't have to worry about the intermediate ast as much, so I combined it into a single statement

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't remember why I had to do it, that totally makes sense

Copy link
Contributor

@edmondop edmondop left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

Ok(())
}

/// DataFusion can convert expressions to SQL, using column name escaping
/// PostgreSQL style.
fn simple_expr_to_sql_demo() -> Result<()> {
let expr = col("a").lt(lit(5)).or(col("a").eq(lit(8)));
let ast = expr_to_sql(&expr)?;
let sql = format!("{}", ast);
let sql = expr_to_sql(&expr)?.to_string();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't remember why I had to do it, that totally makes sense

Copy link
Contributor

@edmondop edmondop left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

lgtm thanks @alamb and @edmondop for review

@comphead comphead merged commit e893a2e into apache:main May 22, 2024
23 checks passed
@alamb alamb deleted the alamb/improve_example_docs branch May 22, 2024 17:49
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants