Skip to content

Conversation

@CuteChuanChuan
Copy link
Contributor

Which issue does this PR close?

Part of #16915

Rationale for this change

Format code examples in documentation comments to improve readability and maintain consistent code style across the codebase. This is part of a multi-PR effort to format all doc comment examples and eventually enable CI checks to enforce this formatting.

What changes are included in this PR?

Run cargo fmt -p <crate> -- --config format_code_in_doc_comments=true for the following datasource-related crates:

  • datafusion-spark
  • datafusion-sql
  • datafusion-sqllogictest
  • datafusion-substrait
  • datafusion-cli
  • datafusion-examples

Are these changes tested?

No testing needed - this is purely a formatting change with no functional modifications.

Are there any user-facing changes?

No - this only affects documentation formatting.

@github-actions github-actions bot added sql SQL Planner sqllogictest SQL Logic Tests (.slt) substrait Changes to the substrait crate spark labels Nov 2, 2025
/// .unwrap()
/// .build()
/// .unwrap();
/// let sql = plan_to_sql(&plan).unwrap(); // convert to AST
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to move // convert to AST to a new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Weijun-H ,

thanks for the feedback! I've moved the // convert to AST comment to a new line.
PTAL when you get a chance. Thanks!

Comment on lines 72 to 75
/// let expr = col("a").gt(lit(4)); // form an expression `a > 4`
/// let sql = expr_to_sql(&expr).unwrap(); // convert to ast::Expr
/// // use the Display impl to convert to SQL text
/// // use the Display impl to convert to SQL text
/// assert_eq!(sql.to_string(), "(a > 4)")
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks funky; might need to move that display comment to be at the end of the assert_eq line or otherwise move all comments to their own line (before their related line of code)

Comment on lines +72 to 77
/// let spans = get_spans(
/// "SELECT /*whole+left*/speed/*left*/ + /*right*/10/*right+whole*/ FROM cars",
/// );
/// // whole is ^^^^^^^^^^^^^^^^^^^^^^^^^^^
/// // left is ^^^^^
/// // right is ^^
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the comments below need to be adjusted as they were referring to the original format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spark sql SQL Planner sqllogictest SQL Logic Tests (.slt) substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants