-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Prestissimo: Fix logic deserializing LongDecimal-typed Data Encoded in INT128_ARRAY in bytestream read #18838
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
Merged
mbasmanova
merged 1 commit into
prestodb:master
from
markjin1990:zhongjun/fix-bytestream-read-int128
Feb 3, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,81 @@ TEST_F(Base64Test, singleTinyint) { | |
| ASSERT_EQ(1, intVector->valueAt(0)); | ||
| } | ||
|
|
||
| TEST_F(Base64Test, simpleLongDecimal) { | ||
| // Note: string values of block representations in following test cases (e.g., | ||
| // "data0") can be obtained by reading the actual block representations of | ||
| // corresponding unscaled values in running services of Prestissimo. | ||
|
|
||
| // Unscaled value = 0 | ||
| const std::string data0 = | ||
| "DAAAAElOVDEyOF9BUlJBWQEAAAAAAAAAAAAAAAAAAAAAAAAAAA=="; | ||
| auto vector0 = readBlock(LONG_DECIMAL(24, 2), data0, pool_.get()); | ||
|
|
||
| ASSERT_EQ(TypeKind::LONG_DECIMAL, vector0->typeKind()); | ||
| ASSERT_EQ(1, vector0->size()); | ||
| ASSERT_FALSE(vector0->isNullAt(0)); | ||
|
|
||
| auto decimalVector0 = | ||
| vector0->as<FlatVector<facebook::velox::UnscaledLongDecimal>>(); | ||
| ASSERT_EQ(UnscaledLongDecimal(0), decimalVector0->valueAt(0)); | ||
|
|
||
| // Unscaled value = 100 | ||
| const std::string data1 = | ||
| "DAAAAElOVDEyOF9BUlJBWQEAAAAAZAAAAAAAAAAAAAAAAAAAAA=="; | ||
| auto vector1 = readBlock(LONG_DECIMAL(24, 2), data1, pool_.get()); | ||
|
|
||
| ASSERT_EQ(TypeKind::LONG_DECIMAL, vector1->typeKind()); | ||
| ASSERT_EQ(1, vector1->size()); | ||
| ASSERT_FALSE(vector1->isNullAt(0)); | ||
|
|
||
| auto decimalVector1 = | ||
| vector1->as<FlatVector<facebook::velox::UnscaledLongDecimal>>(); | ||
| ASSERT_EQ(UnscaledLongDecimal(100), decimalVector1->valueAt(0)); | ||
|
|
||
| // Unscaled value = -100 | ||
| const std::string data2 = | ||
| "DAAAAElOVDEyOF9BUlJBWQEAAAAAZAAAAAAAAAAAAAAAAAAAgA=="; | ||
| auto vector2 = readBlock(LONG_DECIMAL(24, 2), data2, pool_.get()); | ||
|
|
||
| ASSERT_EQ(TypeKind::LONG_DECIMAL, vector2->typeKind()); | ||
| ASSERT_EQ(1, vector2->size()); | ||
| ASSERT_FALSE(vector2->isNullAt(0)); | ||
|
|
||
| auto decimalVector2 = | ||
| vector2->as<FlatVector<facebook::velox::UnscaledLongDecimal>>(); | ||
| ASSERT_EQ(UnscaledLongDecimal(-100), decimalVector2->valueAt(0)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add bigger values (> 64 bit) to the tests with positive and negative values. |
||
|
|
||
| // Unscaled value = 10^20 | ||
| const std::string data3 = | ||
| "DAAAAElOVDEyOF9BUlJBWQEAAAAAAAAQYy1ex2sFAAAAAAAAAA=="; | ||
| auto vector3 = readBlock(LONG_DECIMAL(24, 2), data3, pool_.get()); | ||
|
|
||
| ASSERT_EQ(TypeKind::LONG_DECIMAL, vector3->typeKind()); | ||
| ASSERT_EQ(1, vector3->size()); | ||
| ASSERT_FALSE(vector3->isNullAt(0)); | ||
|
|
||
| auto decimalVector3 = | ||
| vector3->as<FlatVector<facebook::velox::UnscaledLongDecimal>>(); | ||
| ASSERT_EQ( | ||
| UnscaledLongDecimal(DecimalUtil::kPowersOfTen[20]), | ||
| decimalVector3->valueAt(0)); | ||
|
|
||
| // Unscaled value = -10^20 | ||
| const std::string data4 = | ||
| "DAAAAElOVDEyOF9BUlJBWQEAAAAAAAAQYy1ex2sFAAAAAAAAgA=="; | ||
| auto vector4 = readBlock(LONG_DECIMAL(24, 2), data4, pool_.get()); | ||
|
|
||
| ASSERT_EQ(TypeKind::LONG_DECIMAL, vector4->typeKind()); | ||
| ASSERT_EQ(1, vector4->size()); | ||
| ASSERT_FALSE(vector4->isNullAt(0)); | ||
|
|
||
| auto decimalVector4 = | ||
| vector4->as<FlatVector<facebook::velox::UnscaledLongDecimal>>(); | ||
| ASSERT_EQ( | ||
| UnscaledLongDecimal(-DecimalUtil::kPowersOfTen[20]), | ||
| decimalVector4->valueAt(0)); | ||
| } | ||
|
|
||
| TEST_F(Base64Test, singleString) { | ||
| std::string data = "DgAAAFZBUklBQkxFX1dJRFRIAQAAAAoAAAAACgAAADIwMTktMTEtMTA="; | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These string values seem cryptic. Can we directly cast the unscaled values?
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 guess there is metadata involved. Can we construct the payload explicitly?
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.
@markjin1990 Did you push changes to address this comment? It would be easier to verify what exact value been passed in the encoded string if you construct the payload.
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.
@markjin1990 how are these payloads even built now? Can you add 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.
Just added. I basically synthesized some records of the corresponding decimal values in the table and print the value of the 2nd parameter of
base64EncodedofreadBlockto the screen in online running service of Prestissimo when reading these synthesized values. Hope that is clear.Sorry that I haven't found an easy approach automatically synthesizing these values within the unit test and nor the other unit tests have demonstrated their approaches getting these values in the same test file.