Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
baibaichen committed Aug 15, 2024
1 parent a348d72 commit 5844401
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions cpp-ch/local-engine/Parser/CHColumnToSparkRow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,30 +687,8 @@ int64_t VariableLengthDataWriter::writeArray(size_t row_idx, const DB::Array & a
bitSet(buffer_address + offset + start + 8, i);
else
{
if (writer.getWhichDataType().isFloat32())
{
// We can not use safeGet<char>() directly here to process Float32 field,
// because it will get 8 byte data, but Float32 is 4 byte, which will cause error conversion.
auto v = static_cast<Float32>(elem.safeGet<Float32>());
writer.unsafeWrite(
reinterpret_cast<const char *>(&v), buffer_address + offset + start + 8 + len_null_bitmap + i * elem_size);
}
else if (writer.getWhichDataType().isFloat64())
{
// Fix 'Invalid Field get from type Float64 to type Int64' in debug build.
auto v = elem.safeGet<Float64>();
writer.unsafeWrite(reinterpret_cast<const char *>(&v), buffer_address + offset + start + 8 + len_null_bitmap + i * elem_size);
}
else if (writer.getWhichDataType().isDecimal32())
{
// We can not use safeGet<char>() directly here to process Decimal32 field,
// because it will get 4 byte data, but Decimal32 is 8 byte in Spark, which will cause error conversion.
writer.write(elem, buffer_address + offset + start + 8 + len_null_bitmap + i * elem_size);
}
else
writer.unsafeWrite(
reinterpret_cast<const char *>(&elem.safeGet<char>()),
buffer_address + offset + start + 8 + len_null_bitmap + i * elem_size);
// We can not use safeGet<char>() trick, since it will throw an exception if type mismatch
writer.write(elem, buffer_address + offset + start + 8 + len_null_bitmap + i * elem_size);
}
}
}
Expand Down

0 comments on commit 5844401

Please sign in to comment.