Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,20 @@ jobs:
run: cargo check --no-default-features -p datafusion-spark
- name: Check datafusion-spark (core)
run: cargo check --no-default-features --features core -p datafusion-spark

function-docs:
name: function docs up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup toolchain install stable --profile minimal --no-self-update && rustup default stable
- uses: Swatinem/rust-cache@v2
- run: dev/update_function_docs.sh
- name: Check docs/functions is up to date
run: |
if [ -n "$(git status --porcelain -- docs/functions)" ]; then
git status --porcelain -- docs/functions
git diff -- docs/functions
echo "docs/functions is out of date. Run dev/update_function_docs.sh and commit the result."
exit 1
fi
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ DataFusion expressions that emulate Apache Spark's behavior.

- `crates/spark` – the `datafusion-spark` crate
- `crates/sqllogictest` – `.slt` tests for the Spark functions
- `crates/docgen` – generates the `docs/functions` reference from `#[user_doc]` (run `dev/update_function_docs.sh`)

Before opening a PR, run `cargo fmt --all`, `cargo clippy --all-targets --all-features -- -D warnings`,
`cargo test -p datafusion-spark` and `cargo test -p datafusion-spark-sqllogictest`.
If you changed any `#[user_doc]` attribute, also run `dev/update_function_docs.sh` and commit the changes under `docs/functions`.

## Agent Skills

Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ impl ScalarUDFImpl for SparkMyFunc {
See `sha2` (`crates/spark/src/function/hash/sha2.rs`) and `substring`
(`crates/spark/src/function/string/substring.rs`) for complete examples.

The function reference in [`docs/functions`](docs/functions/README.md) is generated from these
attributes, with one page per function category. After adding or changing a function's documentation, regenerate it and commit the
result (CI checks that it is up to date):

```shell
dev/update_function_docs.sh
```

The script also lists, on stderr, the functions that don't implement `documentation()` yet.

## Testing Guidelines

Prefer adding tests via SQLLogicTests where possible, see the [Spark SQLLogicTest README].
Expand Down
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[workspace]
resolver = "2"
members = ["crates/spark", "crates/sqllogictest"]
members = ["crates/docgen", "crates/spark", "crates/sqllogictest"]

[workspace.package]
authors = ["Apache DataFusion <dev@datafusion.apache.org>"]
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ let ctx = SessionContext::new_with_state(state);
let df = ctx.sql("SELECT sha2('Spark', 256)").await?;
```

See the [crate README](crates/spark/README.md) and the [API documentation](https://docs.rs/datafusion-spark)
See the [function reference](docs/functions/README.md) for the documented functions, the
[crate README](crates/spark/README.md) and the [API documentation](https://docs.rs/datafusion-spark)
for more.

## Repository layout
Expand Down
25 changes: 25 additions & 0 deletions crates/docgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
# SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements

[package]
name = "datafusion-spark-docgen"
description = "Generates the function reference for datafusion-spark from #[user_doc]"
version = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
authors = { workspace = true }
license = { workspace = true }
edition = { workspace = true }
publish = false

[lints]
workspace = true

[dependencies]
datafusion-expr = { workspace = true }
datafusion-spark = { path = "../spark" }

[[bin]]
name = "print_functions_docs"
path = "src/main.rs"
Loading
Loading