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

[Bug] Precision Loss in castFromStringInternal for Valid Float Values (e.g., -0.0009163) #4656

Open
2 tasks done
hunshenshi opened this issue Dec 7, 2024 · 1 comment · May be fixed by #4658
Open
2 tasks done

[Bug] Precision Loss in castFromStringInternal for Valid Float Values (e.g., -0.0009163) #4656

hunshenshi opened this issue Dec 7, 2024 · 1 comment · May be fixed by #4658
Labels
bug Something isn't working

Comments

@hunshenshi
Copy link

hunshenshi commented Dec 7, 2024

Search before asking

  • I searched in the issues and found nothing similar.

Paimon version

paimon-flink-1.18-1.0-SNAPSHOT.jar

Compute Engine

flink

Minimal reproduce step

create table in mysql

CREATE TABLE `example_table` (
  `id` bigint NOT NULL,
  `value` float DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

and insert data

INSERT INTO example_table (id, value) VALUES (1, -0.0009163);

What doesn't meet your expectations?

Float f = Float.valueOf(s);
if (f.toString().length() != s.length()) {
    throw new NumberFormatException(
            s + " cannot be cast to float due to precision loss");
} else {
    return f;
}

Precision checking should not strictly rely on comparing the lengths of the values. As a result, values such as -0.0009163 and similar ones, which can be safely represented in MySQL FLOAT, are mistakenly rejected.

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@hunshenshi hunshenshi added the bug Something isn't working label Dec 7, 2024
hunshenshi added a commit to hunshenshi/paimon that referenced this issue Dec 7, 2024
@hunshenshi hunshenshi linked a pull request Dec 7, 2024 that will close this issue
@hunshenshi
Copy link
Author

@herefree can you help me review this? thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant