apache / apache/datafusion

PostgreSQL compatibility: `ln(-1.0::float8)` should error, not return NaN

Open
#22,271 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

Split out from #22247.

### Mismatch

`ln(-1.0::float8)` should error, not return NaN.

```sql
SELECT ln((-1.0)::float8);
```

PostgreSQL:

```text
ERROR: cannot take logarithm of a negative number
```

DataFusion:

```text
NaN
```

### Expected behavior

For PostgreSQL-compatible SQL semantics, DataFusion should either match PostgreSQL's result or raise the same class of domain/semantic error.

Contributor guide

Open the contributing guide

Research direction

Search DataFusion's Rust implementation and tests for the ln function on float8 values, starting with the handling of negative inputs. Use SELECT ln((-1.0)::float8) as the reproduction and verify that the completed behavior raises a PostgreSQL-compatible domain or semantic error instead of returning NaN.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, rust
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.