Skip to content

Commit

Permalink
[GLUTEN-2584][CH] Fix mismatch complex type values during native orc …
Browse files Browse the repository at this point in the history
…writing (ClickHouse#454)
  • Loading branch information
taiyang-li committed Aug 15, 2023
1 parent 81a71db commit 22a8043
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Processors/Formats/Impl/ORCBlockOutputFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,11 @@ void ORCBlockOutputFormat::writeColumn(
for (size_t i = 0; i != column_size; ++i)
{
list_orc_column.offsets[i + 1] = offsets[i];
list_orc_column.notNull[i] = 1;
list_orc_column.notNull[i] = (null_bytemap && (*null_bytemap)[i]) ? 0 : 1;
}

orc::ColumnVectorBatch & nested_orc_column = *list_orc_column.elements;
writeColumn(nested_orc_column, list_column.getData(), nested_type, null_bytemap);
writeColumn(nested_orc_column, list_column.getData(), nested_type, nullptr);
list_orc_column.numElements = column_size;
break;
}
Expand All @@ -503,8 +503,10 @@ void ORCBlockOutputFormat::writeColumn(
orc::StructVectorBatch & struct_orc_column = dynamic_cast<orc::StructVectorBatch &>(orc_column);
const auto & tuple_column = assert_cast<const ColumnTuple &>(column);
auto nested_types = assert_cast<const DataTypeTuple *>(type.get())->getElements();

for (size_t i = 0; i != tuple_column.size(); ++i)
struct_orc_column.notNull[i] = 1;
struct_orc_column.notNull[i] = (null_bytemap && (*null_bytemap)[i]) ? 0 : 1;

for (size_t i = 0; i != tuple_column.tupleSize(); ++i)
writeColumn(*struct_orc_column.fields[i], tuple_column.getColumn(i), nested_types[i], null_bytemap);
break;
Expand All @@ -524,17 +526,17 @@ void ORCBlockOutputFormat::writeColumn(
for (size_t i = 0; i != column_size; ++i)
{
map_orc_column.offsets[i + 1] = offsets[i];
map_orc_column.notNull[i] = 1;
map_orc_column.notNull[i] = (null_bytemap && (*null_bytemap)[i]) ? 0 : 1;
}
const auto nested_columns = assert_cast<const ColumnTuple *>(list_column.getDataPtr().get())->getColumns();

orc::ColumnVectorBatch & keys_orc_column = *map_orc_column.keys;
auto key_type = map_type.getKeyType();
writeColumn(keys_orc_column, *nested_columns[0], key_type, null_bytemap);
writeColumn(keys_orc_column, *nested_columns[0], key_type, nullptr);

orc::ColumnVectorBatch & values_orc_column = *map_orc_column.elements;
auto value_type = map_type.getValueType();
writeColumn(values_orc_column, *nested_columns[1], value_type, null_bytemap);
writeColumn(values_orc_column, *nested_columns[1], value_type, nullptr);

map_orc_column.numElements = column_size;
break;
Expand Down

0 comments on commit 22a8043

Please sign in to comment.