Repository navigation
docs: show runnable query examples in API documentation - #26291
Harshil-1603 wants to merge 3 commits into
Conversation
|
Can you please post an annotated screen shot of what this change does? |
alamb
left a comment
There was a problem hiding this comment.
Thank you for this @Harshil-1603
I am worried about creating yet-another-copy of the examples that has to be maintained.
What would you think about instead adding links to the docs to make our existing examples easier to find?
| use datafusion::error::Result; | ||
| use datafusion::prelude::*; | ||
|
|
||
| #[tokio::main(flavor = "current_thread")] |
There was a problem hiding this comment.
There is a whole crate of examples here: https://github.com/apache/datafusion/tree/main/datafusion-examples
This one, for example, is pretty similar to a bunch of existing examples
- (register_batch + sql + filter + collect + assert_batches_eq)
datafusion/docs/source/library-user-guide/using-the-dataframe-api.md
Lines 78 to 112 in 0d79252
- (read_memory runnable example)
datafusion/datafusion-examples/examples/dataframe/dataframe.rs
Lines 160 to 178 in 0d79252
I realize we can't reuse datafusion-examples without moving them all to the core crate which is a more substantial change.
|
Or maybe given the doc-scrape-examples feature, we should consider moving all the examples back into the core crate? |
|
Thanks for the contribution! I am closing this under DataFusion's AI Dump policy. This has the hallmarks of AI code that was not reviewed by the author: a testing section admitting clippy and the extended tests did not pass, a new example duplicating existing ones, and no reply to the maintainer design question from 2026-10-16. If you would like to continue, please open a focused PR in your own words that you have reviewed and understand, and we are happy to help with review. |

Which issue does this PR close?
Closes #16654.
Rationale for this change
API readers currently need to follow manually maintained links to discover complete runnable examples. Enable rustdoc's example scraping so the API reference displays real call sites next to the methods they demonstrate.
What changes are included in this PR?
datafusioncrate's docs.rs build.This establishes scraping for the core crate. The separate
datafusion-examplescatalogue is not moved or bundled into the published library.What is the testing strategy for this PR?
Passed locally on Rust 1.99.0, with nightly 1.101.0-nightly (2026-10-14) for rustdoc:
cargo fmt --all -- --checkcargo clippy --locked -p datafusion --example query --all-features -- -D warningscargo run --locked -p datafusion --example query(checks the SQL and DataFrame results against expected rows)cargo +nightly doc --locked -p datafusion --all-features --lib --no-deps -Z unstable-options -Z rustdoc-scrape-examples, withRUSTDOCFLAGS=-D warningscargo package --locked -p datafusion --allow-dirty --no-verifyand inspection of the resulting archive to confirm the example and scraping configuration are included./ci/scripts/doc_prettier_check.sh --write --allow-dirtygit diff --checkA normal nightly documentation build had no scraped example panels. With scraping enabled, the
SessionContextandDataFramepages contain source-linked panels fromquery.rs. TheSessionContext::sqlpanel was inspected in a browser; no console errors were present (rustdoc produced font-preload warnings).The required full
cargo clippy --locked --all-targets --all-features -- -D warningsfails with three existingclippy::mutable_key_typeerrors in unchangeddatafusion/optimizer/src/push_down_filter.rs, tracked by #26181. The focused example check passes. The full lint suite and extended tests have not passed.Are there any user-facing changes?
The API documentation now includes automatically extracted query examples and links to their source. No runtime behavior or public API changes.
Prepared with Codex assistance. Author and maintainer review remain necessary; hosted docs.rs behavior will be verified after publication.
@alamb Could you trigger CI for this first contribution?