Repository navigation
ORC-1385: [C++] Support schema evolution of numeric types - #1454
Conversation
| std::shared_ptr<Type>& getReadType() const; | ||
|
|
||
| /** | ||
| * Set should reader throw a exception on conversion between different data types overflow |
There was a problem hiding this comment.
| * Set should reader throw a exception on conversion between different data types overflow | |
| * Set whether reader throws or returns null when value overflows for schema evolution. |
| RowReaderOptions& throwOnSchemaEvolutionOverflow(bool shouldThrow); | ||
|
|
||
| /** | ||
| * Get should reader throw a exception on conversion between different data types overflow |
There was a problem hiding this comment.
| * Get should reader throw a exception on conversion between different data types overflow | |
| * Whether reader throws or returns null when value overflows for schema evolution. |
|
|
||
| // whether the vector is not a numeric vector | ||
| // or it's created with the option useTightNumericVector | ||
| bool isTight = true; |
There was a problem hiding this comment.
Is it possible not to add this? The reader can get this information by the provided ReaderOption
There was a problem hiding this comment.
But, what if the ColumnVectorBatch is created by another reader which was createed without the useTightNumericVector option?
There was a problem hiding this comment.
Does the current ColumnReader have same issue?
There was a problem hiding this comment.
Does the current
ColumnReaderhave same issue?
Yes, I think there is.
There was a problem hiding this comment.
We probably need to fix that as well.
What about adding a new function to ColumnVectorBatch like int32_t fixed_type_size() const to return the width in bytes for fixed length type? For variable length type or nested type we can return -1.
There was a problem hiding this comment.
What probably need to fix that as well.
What about adding a new function to
ColumnVectorBatchlikeint32_t fixed_type_size() constto return the width in bytes for fixed length type? For variable length type or nested type we can return -1.
I think what we are going to do is handle incorrect usage by users (such as passing a vector that was created by other readers). However, we don’t know what causes the failure of casting. The vector may have been created by another reader with a different read type from the current reader, or it may have been created by another reader with a different useTightNumericVector option. fixed_type_size() may not help us infer what the user did wrong, but with isTight, we could suggest that the user check their options.
There was a problem hiding this comment.
OK, that sounds good.
However, isTight here is a little bit confusing since it applies to only numeric types. We need to be careful to add any field to the public api. And it should also be used with its type together.
In the ColumnReader, we always check the result of dynamic_cast of the vector batch. Is it enough if we can use dynamic_cast and check if it is not null in the ConvertColumnReader?
There was a problem hiding this comment.
OK, that sounds good.
However,
isTighthere is a little bit confusing since it applies to only numeric types. We need to be careful to add any field to the public api. And it should also be used with its type together.In the
ColumnReader, we always check the result of dynamic_cast of the vector batch. Is it enough if we can use dynamic_cast and check if it is not null in theConvertColumnReader?
I think that's OK, so we will only verify the ReaderOption and check the result of dynamic_cast in ConvertColumnReader.
| rowBatch.numElements = data->numElements; | ||
| rowBatch.hasNulls = data->hasNulls; | ||
| if (!rowBatch.hasNulls) { | ||
| memset(rowBatch.notNull.data(), 1, data->notNull.size()); |
There was a problem hiding this comment.
I guess this is not required
Lines 120 to 127 in 070c1a5
When there are no nulls and we are going to set null when an overflow in conversion occurs, the
notNull of other elements should be 1, but they are 0 after resizing, so the memset is needed.
| if (!canFitInLong(static_cast<double>(srcValue)) || | ||
| !downCastToInteger(destValue, longValue)) { | ||
| handleOverflow<FileType, ReadType>(destBatch, idx, shouldThrow); | ||
| return; |
|
|
||
| public: | ||
| StructColumnReader(const Type& type, StripeStreams& stipe, bool useTightNumericVector = false); | ||
| StructColumnReader(const Type& type, StripeStreams& stipe, bool useTightNumericVector = false, |
There was a problem hiding this comment.
I am thinking if we can use a new ColumnReaderOptions to include useTightNumericVector and throwOnSchemaEvolutionOverflow in case we will add more options. But that can be a separate patch since this is not public.
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include <iostream> |
There was a problem hiding this comment.
This patch does not seem to depend on the header file?
| bool getIsDecimalAsLong() const; | ||
| int32_t getForcedScaleOnHive11Decimal() const; | ||
|
|
||
| const SchemaEvolution& getSchemaEvolution() const { |
There was a problem hiding this comment.
Is it possible to consider unifying the return type(const SchemaEvolution*) of the getSchemaEvolution() function in class StripeStreams and class RowReaderImpl.
coderex2522
left a comment
There was a problem hiding this comment.
+1 LGTM. Thanks @ffacs
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Hi, All.
This code seems to cause a build failure on Clang-Ubuntu environment. Not only old Clang 10.0.0 on Ubuntu 20.04 but also Clang 14.0.0 on Ubuntu 22.04 complains about this patch. Could you take a look at this?
|
Could you double check this compilation issue, @ffacs , @wgtmac , @coderex2522 ? |
| switch (fileType.getKind()) { | ||
| case BOOLEAN: { | ||
| switch (_readType.getKind()) { | ||
| CASE_CREATE_READER(BYTE, BooleanToByte); |
There was a problem hiding this comment.
For example, ; is required in this line?
There was a problem hiding this comment.
How did you get the failure? Via docker test?
### What changes were proposed in this pull request?
support schema evolution converting between types within {boolean, tinyint, smallint, int, bigint, float, double}
### Why are the changes needed?
To support schema evolution in c++
### How was this patch tested?
UT passed
This closes apache#1454
What changes were proposed in this pull request?
support schema evolution converting between types within {boolean, tinyint, smallint, int, bigint, float, double}
Why are the changes needed?
To support shecma evolution in c++
How was this patch tested?
UT passed