Skip to content

fix: Avoid incorrectly rounding large integers in nanvl#22575

Open
neilconway wants to merge 2 commits into
apache:mainfrom
neilconway:neilc/fix-nanvl-integer-precision
Open

fix: Avoid incorrectly rounding large integers in nanvl#22575
neilconway wants to merge 2 commits into
apache:mainfrom
neilconway:neilc/fix-nanvl-integer-precision

Conversation

@neilconway
Copy link
Copy Markdown
Contributor

@neilconway neilconway commented May 27, 2026

Which issue does this PR close?

Rationale for this change

nanvl's function signature listed Float16 first, which meant that data types not natively supported by the function (e.g., integers) would be converted to Float16. This resulted in unnecessary and incorrect rounding for large integer inputs (e.g., nanvl(16777217, 1) returned incorrect results).

Instead, we now convert non-floating point inputs to Float64. This might still round for inputs larger than 2^53, but it's the best we can do without more fundamental changes. Floating point inputs are coerced to the widest float type they have in common -- e.g., (Float16, Float32) -> Float32.

What changes are included in this PR?

  • Change function signature to avoid unnecessary rounding
  • Update SLT

Are these changes tested?

Yes; new tests added.

Are there any user-facing changes?

Yes; nanvl now avoids rounding in more cases.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nanvl incorrectly rounds on integer input

1 participant