Skip to content

Commit

Permalink
HIVE-26892: Backport HIVE-25243 to 3.2.0: Handle nested values in nul…
Browse files Browse the repository at this point in the history
…l struct. (#3898) (branch-3 backport by Aman Raj reviewed by Laszlo Bodor)
  • Loading branch information
cnauroth committed Jan 10, 2023
1 parent 98078b1 commit 3e31a07
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ql/src/java/org/apache/hadoop/hive/ql/io/arrow/Serializer.java
Expand Up @@ -267,6 +267,21 @@ private void writeStruct(NonNullableStructVector arrowVector, StructColumnVector
final ColumnVector[] hiveFieldVectors = hiveVector.fields;
final int fieldSize = fieldTypeInfos.size();

// This is to handle following scenario -
// if any struct value itself is NULL, we get structVector.isNull[i]=true
// but we don't get the same for it's child fields which later causes exceptions while setting to arrow vectors
// see - https://issues.apache.org/jira/browse/HIVE-25243
if (hiveVector != null && hiveFieldVectors != null) {
for (int i = 0; i < size; i++) {
if (hiveVector.isNull[i]) {
for (ColumnVector fieldVector : hiveFieldVectors) {
fieldVector.isNull[i] = true;
fieldVector.noNulls = false;
}
}
}
}

for (int fieldIndex = 0; fieldIndex < fieldSize; fieldIndex++) {
final TypeInfo fieldTypeInfo = fieldTypeInfos.get(fieldIndex);
final ColumnVector hiveFieldVector = hiveFieldVectors[fieldIndex];
Expand Down

0 comments on commit 3e31a07

Please sign in to comment.