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

Parquet record api: display for float/double 0.0 shows 0E0 #5045

Closed
Jefffrey opened this issue Nov 7, 2023 · 2 comments
Closed

Parquet record api: display for float/double 0.0 shows 0E0 #5045

Jefffrey opened this issue Nov 7, 2023 · 2 comments
Labels
bug development-process Related to development process of arrow-rs parquet Changes to the parquet crate

Comments

@Jefffrey
Copy link
Contributor

Jefffrey commented Nov 7, 2023

Describe the bug

Floats and doubles that are zero (or negative zero) are displayed in format 0E0 for Field from record api

To Reproduce

In unit test:

#[test]
fn test_convert_float_to_string() {
assert_eq!(format!("{}", Field::Float(1.0)), "1.0");
assert_eq!(format!("{}", Field::Float(9.63)), "9.63");
assert_eq!(format!("{}", Field::Float(1e-15)), "0.000000000000001");
assert_eq!(format!("{}", Field::Float(1e-16)), "1E-16");
assert_eq!(format!("{}", Field::Float(1e19)), "10000000000000000000.0");
assert_eq!(format!("{}", Field::Float(1e20)), "1E20");
assert_eq!(format!("{}", Field::Float(1.7976931E30)), "1.7976931E30");
assert_eq!(format!("{}", Field::Float(-1.7976931E30)), "-1.7976931E30");
}

Modify to add new case:

    #[test]
    fn test_convert_float_to_string() {
        assert_eq!(format!("{}", Field::Float(1.0)), "1.0");
        assert_eq!(format!("{}", Field::Float(9.63)), "9.63");
        assert_eq!(format!("{}", Field::Float(1e-15)), "0.000000000000001");
        assert_eq!(format!("{}", Field::Float(1e-16)), "1E-16");
        assert_eq!(format!("{}", Field::Float(1e19)), "10000000000000000000.0");
        assert_eq!(format!("{}", Field::Float(1e20)), "1E20");
        assert_eq!(format!("{}", Field::Float(1.7976931E30)), "1.7976931E30");
        assert_eq!(format!("{}", Field::Float(-1.7976931E30)), "-1.7976931E30");
        assert_eq!(format!("{}", Field::Float(0.0)), "0.0"); // new test case, should succeed
    }

Running test will fail:

parquet$ cargo test --lib record::api::tests::test_convert_float_to_string -- --exact
    Finished test [unoptimized + debuginfo] target(s) in 0.06s
     Running unittests src/lib.rs (/media/jeffrey/1tb_860evo_ssd/.cargo_target_cache/debug/deps/parquet-b466af98c7f74484)

running 1 test
test record::api::tests::test_convert_float_to_string ... FAILED

failures:

---- record::api::tests::test_convert_float_to_string stdout ----
thread 'record::api::tests::test_convert_float_to_string' panicked at parquet/src/record/api.rs:1158:9:
assertion `left == right` failed
  left: "0E0"
 right: "0.0"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    record::api::tests::test_convert_float_to_string

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 616 filtered out; finished in 0.00s

error: test failed, to rerun pass `--lib`

Expected behavior

Test case succeeds

Additional context

@Jefffrey
Copy link
Contributor Author

Jefffrey commented Nov 7, 2023

Closed as not necessary to change

@Jefffrey Jefffrey closed this as completed Nov 7, 2023
@tustvold tustvold added the parquet Changes to the parquet crate label Nov 7, 2023
@tustvold
Copy link
Contributor

tustvold commented Nov 7, 2023

label_issue.py automatically added labels {'parquet'} from #5046

@tustvold tustvold added the development-process Related to development process of arrow-rs label Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug development-process Related to development process of arrow-rs parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants