-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Make sqllogictest platform-independent for the sign of NaN #7462
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
Conversation
| query R | ||
| SELECT * FROM test_float WHERE column1 IN (0.0, 1.2, 'NaN'::double, '-NaN'::double) | ||
| query T | ||
| SELECT column1 FROM test_float WHERE column2 IN (0.0, 1.2, 'NaN'::double, '-NaN'::double) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified this test which is sign sensitive not to show NaN and -NaN.
| } else { | ||
| "-NaN".to_string() | ||
| } | ||
| "NaN".to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, you mean on different platform, a same value could be positive and negative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, maybe it good to leave a comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. a function/operation can return -NaN on x86 while NaN on Arm.
| # select NaNs | ||
| query RRRR | ||
| select 'NaN'::double a, '-NaN'::double b, 'NaN'::float c, '-NaN'::float d | ||
| ---- | ||
| NaN -NaN NaN -NaN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even simply literals also are impacted, i.e. platform dependent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so.
I believe NaN and -NaN are finally parsed here.
So, as long as f32::NAN, f64::NAN, -f32::NAN and -f64::NAN follows IEEE 754, simple literals should not be impacted.
But the string representation needs to be NaN regardless of NaN or -NaN.
So this test should be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave the test to show the behavior of parsing -NaN.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Hi @sarutak. |
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sarutak -- I think this change is reasonable to me
| # select NaNs | ||
| query RRRR | ||
| select 'NaN'::double a, '-NaN'::double b, 'NaN'::float c, '-NaN'::float d | ||
| ---- | ||
| NaN -NaN NaN -NaN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave the test to show the behavior of parsing -NaN.
|
Looks good to me -- thank you @sarutak |
Which issue does this PR close?
Closes #7458
Rationale for this change
The sign of
NaNreturned from a function seems to depend on platform.But it's better for
sqllogictestto be platform-independent.What changes are included in this PR?
Revert #7403 and change one test which is sign sensitive .
Are these changes tested?
cargo test --test sqllogictestspassed.Are there any user-facing changes?
No.