Skip to content

Fix precision loss in large integral string conversions#3405

Open
fallintoplace wants to merge 2 commits into
apache:mainfrom
fallintoplace:fix-integral-string-precision
Open

Fix precision loss in large integral string conversions#3405
fallintoplace wants to merge 2 commits into
apache:mainfrom
fallintoplace:fix-integral-string-precision

Conversation

@fallintoplace
Copy link
Copy Markdown
Contributor

@fallintoplace fallintoplace commented May 22, 2026

Summary

Fixes precision loss when converting large integral strings in two runtime paths:

  • StringLiteral.to(IntegerType/LongType)
  • partition_to_py(...) for integral and time-based partition values backed by integers

Root cause

Both paths were converting through float before converting to int, which loses precision for values outside the IEEE-754 exact integer range.

That caused valid 64-bit integers like LongType.max and 9007199254740993 to be corrupted.

What changed

  • Replaced int(float(...)) with exact integer parsing in partition_to_py
  • For StringLiteral.to(IntegerType/LongType), exact integral strings now use exact integer parsing while fractional numeric strings retain the existing truncation behavior
  • Added regression tests for LongType.max and 9007199254740993

Validation

  • uv run pytest tests/expressions/test_literals.py tests/test_conversions.py

Closes #3404.

@fallintoplace fallintoplace marked this pull request as ready for review May 22, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Large integral string values lose precision in literal and partition conversion

1 participant