Skip to content

docs: fix signum documentation to say zero returns 0 - #24324

Merged
Jefffrey merged 1 commit into
apache:mainfrom
codeAnqiang-ma:docs/signum-zero-returns-zero
Aug 14, 2026
Merged

docs: fix signum documentation to say zero returns 0#24324
Jefffrey merged 1 commit into
apache:mainfrom
codeAnqiang-ma:docs/signum-zero-returns-zero

Conversation

@codeAnqiang-ma

Copy link
Copy Markdown
Contributor

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 #11580 (issue #11557). Only the docs
were left describing the pre-#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.

The `#[user_doc]` description for `signum` said "Zero and positive numbers
return `1`", but `signum(0)` returns `0`. The repository's own tests already
assert this: scalar.slt checks `select signum(-2), signum(0), signum(2);`
returns `-1 0 1`, and the signum unit tests assert `signum(±0.0) == 0.0`.

That behavior is intentional and matches PostgreSQL `sign()` and Spark
`signum()`; it was changed on purpose in apache#11580 (issue apache#11557). Only the
documentation was left describing the old behavior, so this updates the
description and regenerates docs/source/user-guide/sql/scalar_functions.md
with dev/update_function_docs.sh. No behavior change.

Assisted-by: Cursor (Opus 5)
@github-actions github-actions Bot added documentation Improvements or additions to documentation functions Changes to functions implementation labels Aug 13, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.14%. Comparing base (ab12f5e) to head (90d4e13).
⚠️ Report is 18 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24324      +/-   ##
==========================================
- Coverage   81.14%   81.14%   -0.01%     
==========================================
  Files        1112     1112              
  Lines      386933   386933              
  Branches   386933   386933              
==========================================
- Hits       313967   313958       -9     
- Misses      54476    54481       +5     
- Partials    18490    18494       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Jefffrey Jefffrey left a comment

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.

word of advice if there is a human looking at this; the PR description doesnt need to be that verbose for such a simple change. theres elegance in being succinct

@Jefffrey
Jefffrey added this pull request to the merge queue Aug 14, 2026
Merged via the queue into apache:main with commit a635b18 Aug 14, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants