Skip to content

Commit a635b18

Browse files
docs: fix signum documentation to say zero returns 0 (apache#24324)
## Which issue does this PR close? N/A — documentation-only correction; no open issue tracks it. ## Rationale for this change The user guide for `signum` says "Zero and positive numbers return `1`", but `signum(0)` returns `0` — the documented return value for zero is the opposite of what the function does. The repository's own tests already pin the real behavior: - `datafusion/sqllogictest/test_files/scalar.slt`: `select signum(-2), signum(0), signum(2);` → `-1 0 1` - The unit tests in `signum.rs` assert `signum(±0.0) == 0.0` That behavior is intentional: it matches PostgreSQL `sign()` and Spark `signum()`, and was changed on purpose in apache#11580 (issue apache#11557). Only the docs were left describing the pre-apache#11580 behavior, so this PR updates the docs, not the code. ## What changes are included in this PR? Documentation only: - Update the `#[user_doc]` description in `datafusion/functions/src/math/signum.rs` to state that zero returns `0`. - Regenerate `docs/source/user-guide/sql/scalar_functions.md` via `dev/update_function_docs.sh`. ## Are these changes tested? No new tests: the corrected wording describes behavior the existing tests above already assert, and those are what it was checked against. - `cargo test -p datafusion-functions --lib math::signum` → 2 passed - `cargo fmt --all -- --check` and `./ci/scripts/doc_prettier_check.sh` → clean ## Are there any user-facing changes? Yes, documentation only. No API or runtime behavior change. --- Prepared with AI assistance; every claim above was verified locally against the repository's existing tests before opening this PR. Co-authored-by: codeAnqiang-ma <[email protected]>
1 parent 6b7da9a commit a635b18

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎datafusion/functions/src/math/signum.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ use datafusion_macros::user_doc;
3434
doc_section(label = "Math Functions"),
3535
description = r#"Returns the sign of a number.
3636
Negative numbers return `-1`.
37-
Zero and positive numbers return `1`."#,
37+
Zero returns `0`.
38+
Positive numbers return `1`."#,
3839
syntax_example = "signum(numeric_expression)",
3940
standard_argument(name = "numeric_expression", prefix = "Numeric"),
4041
sql_example = r#"```sql

‎docs/source/user-guide/sql/scalar_functions.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,8 @@ round(numeric_expression[, decimal_places])
796796

797797
Returns the sign of a number.
798798
Negative numbers return `-1`.
799-
Zero and positive numbers return `1`.
799+
Zero returns `0`.
800+
Positive numbers return `1`.
800801

801802
```sql
802803
signum(numeric_expression)

0 commit comments

Comments
 (0)