koopatroopa787 opened a new pull request, #22735: URL: https://github.com/apache/datafusion/pull/22735
## Which issue does this PR close? Closes #22271 ## Rationale for this change PostgreSQL raises an error when `ln()` receives a non-positive argument: - `ln(0)` → `ERROR: cannot take logarithm of zero` - `ln(-1)` → `ERROR: cannot take logarithm of a negative number` DataFusion was silently returning `-Infinity` for zero and `NaN` for negatives, diverging from PostgreSQL semantics. ## What changes are included in this PR? - `datafusion/functions/src/math/mod.rs`: Added `validate_ln_input` (same pattern as the existing `validate_sqrt_input`) and passed it as the `$VALIDATOR` argument to the `LnFunc` macro invocation. - `datafusion/sqllogictest/test_files/scalar.slt`: Updated `ln(0)` and negative-value tests to expect errors; added explicit `ln(-1.0)` and `ln(-0.5)` error assertions; replaced the `signed_integers` column test (which contained negative values) with a simple positive-literal array test. ## Are there any user-facing changes? Yes — `ln(0)` and `ln(<negative>)` now raise errors instead of returning `-Infinity` / `NaN`. This is a bug fix for PostgreSQL compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
