From 5844401b1243dac64e80a9a9eafb3873d6fabc9f Mon Sep 17 00:00:00 2001 From: Chang Chen Date: Wed, 14 Aug 2024 21:57:28 +0800 Subject: [PATCH] Fix UT due to https://github.com/ClickHouse/ClickHouse/pull/68135 --- .../Parser/CHColumnToSparkRow.cpp | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/cpp-ch/local-engine/Parser/CHColumnToSparkRow.cpp b/cpp-ch/local-engine/Parser/CHColumnToSparkRow.cpp index 80902b22324b9..ad55754f11eb4 100644 --- a/cpp-ch/local-engine/Parser/CHColumnToSparkRow.cpp +++ b/cpp-ch/local-engine/Parser/CHColumnToSparkRow.cpp @@ -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() 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(elem.safeGet()); - writer.unsafeWrite( - reinterpret_cast(&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(); - writer.unsafeWrite(reinterpret_cast(&v), buffer_address + offset + start + 8 + len_null_bitmap + i * elem_size); - } - else if (writer.getWhichDataType().isDecimal32()) - { - // We can not use safeGet() 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(&elem.safeGet()), - buffer_address + offset + start + 8 + len_null_bitmap + i * elem_size); + // We can not use safeGet() trick, since it will throw an exception if type mismatch + writer.write(elem, buffer_address + offset + start + 8 + len_null_bitmap + i * elem_size); } } }