Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Better casts to string for binary floats/doubles #1078

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

nj1973
Copy link
Contributor

@nj1973 nj1973 commented Jan 16, 2024

This PR is to work around problems validating floating point values where some engines return all digits and others return scientific notation, for example:

1.23456781E+007         │ 12345678.1

Changes in the PR:

  • Use SQL Server FORMAT() instead of CAST() for real/float columns. In my tests that ensures we do not end up with scientific notation
  • Use Teradata TO_CHAR('TM9') instead of CAST() for binary_float/double columns. In my tests that ensures we do not end up with scientific notation
  • Use Oracle TO_CHAR('TM9') instead of CAST() for binary_float/double columns. In my tests that ensures we do not end up with scientific notation but we still get some unpredicatable values due to the lossy nature of binary floats. For this reason the column remain excluded from Oracle integration tests
  • Reduces code duplication by importing the original Ibis _cast() function and calling that when not in one of our workarounds

Problems not fixed by this PR:

  • Hive float and double remain problematic
  • Oracle binary_float/double remain problematic

@nj1973
Copy link
Contributor Author

nj1973 commented Jan 17, 2024

/gcbrun

Copy link
Collaborator

@nehanene15 nehanene15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I like the idea of importing sa_fixed_cast() to clean up the code

@nj1973 nj1973 merged commit 15bfc4c into develop Jan 22, 2024
5 checks passed
@nj1973 nj1973 deleted the 841-binary-float-in-scientific-notation branch January 22, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

validate row: Binary float and double values in scientific notation which does not match BigQuery
2 participants