Skip to content

docs(dataframe): add dataframe aggregation example (#26597) - #26600

Merged
neilconway merged 7 commits into
apache:mainfrom
cj-zhukov:cj-zhukov/docs-aggregate-examples
Oct 25, 2026
Merged

neilconway merged 7 commits into
apache:mainfrom
cj-zhukov:cj-zhukov/docs-aggregate-examples

Conversation

@cj-zhukov

@cj-zhukov cj-zhukov commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

datafusion-examples has no example about aggregation with the DataFrame API. aggregate(vec![], ...) only appears inside other examples (subqueries, UDAFs), and nothing shows the select form added in #25482. Users have no place to see when select is enough and when they still need aggregate.

What changes are included in this PR?

  • New example datafusion-examples/examples/dataframe/aggregate.rs, run with cargo run --example dataframe -- aggregate
  • dataframe/main.rs: new aggregate subcommand.
  • datafusion-examples/README.md: generated row for the new example.

No library code is changed

What is the testing strategy for this PR?

cargo run --example dataframe -- aggregate and cargo run --example dataframe -- all run without errors.
./ci/scripts/check_examples_docs.sh passes (README matches the generator).

Are there any user-facing changes?

No. Examples and README only.

@cj-zhukov cj-zhukov changed the title add DataFrame aggregation example (#26597) docs(dataframe): add dataframe aggregation example (#26597) Oct 22, 2026
//! - `all` — run all examples included in this module
//!
//! - `aggregate`
//! (file: aggregate.rs, desc: Global and grouped aggregation with select and `aggregate`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be `select` I think

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I named it aggregate because the examples focus on aggregation, but I see your point that select better highlights the new API. I'll consider how to make the distinction between the two approaches clearer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, my comment wasn't clear. I only meant that "select" in the description should be in backticks to match "aggregate"; I wasn't suggesting a rename. I think "aggregate" is the better name

Comment thread datafusion-examples/examples/dataframe/aggregate.rs Outdated
cj-zhukov and others added 5 commits October 25, 2026 16:46
The aggregate_in_select row was edited by hand. Its link text still said
dataframe/aggregate.rs, and the table padding still fit the old, longer
description, so check_examples_docs.sh reported the README as out of
date. Running check_examples_docs.sh --write fixes both.
The example covers grouped aggregation with `aggregate` as well as
aggregate functions in `select`, so `aggregate` names all of it. The
name also matches issue apache#26597. The description goes back to "Global
and grouped aggregation with `select` and `aggregate`", now with
backticks on `select`, and the README row is regenerated to match.
The "One step" comment put backticks on "accepts" instead of on the
method name `select`. The Aggregate match arm now uses the same block
form with a trailing semicolon as the other arms.
@neilconway

Copy link
Copy Markdown
Contributor

@cj-zhukov I took the liberty of pushing a few minor fixes to your branch, to save the back-and-forth. Thanks for your work on this!

@neilconway
neilconway enabled auto-merge October 25, 2026 16:13
@neilconway
neilconway added this pull request to the merge queue Oct 25, 2026
@cj-zhukov

Copy link
Copy Markdown
Contributor Author

@neilconway Thanks a lot for your review and guidance throughout this PR! I really appreciate your time and help.

Merged via the queue into apache:main with commit da11e68 Oct 25, 2026
45 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add DataFrame aggregation example (select vs aggregate)

2 participants