From b03b83db3ee70f9c6a82edf2923f60fb62f0ec14 Mon Sep 17 00:00:00 2001 From: Jack Del Vecchio Date: Thu, 19 Oct 2023 16:59:58 +0000 Subject: [PATCH] HPCC-30524 Parquet Strings cannot be converted to REAL --- plugins/parquet/parquetembed.cpp | 39 ++++++++++++++++++++++++++++---- plugins/parquet/parquetembed.hpp | 1 + 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/plugins/parquet/parquetembed.cpp b/plugins/parquet/parquetembed.cpp index 749b14d35b6..290766733a9 100644 --- a/plugins/parquet/parquetembed.cpp +++ b/plugins/parquet/parquetembed.cpp @@ -956,12 +956,44 @@ __int64 ParquetRowBuilder::getCurrIntValue(const RtlFieldInfo *field) { __int64 myint64 = 0; auto scalar = getCurrView(field); - handleDeserializeOutcome(tokenDeserializer.deserialize(scalar.data(), myint64), "signed", scalar.data()); + std::string scalarStr(scalar.data(), scalar.size()); + handleDeserializeOutcome(tokenDeserializer.deserialize(scalarStr.c_str(), myint64), "signed", scalarStr.c_str()); return myint64; } } } +double ParquetRowBuilder::getCurrRealValue(const RtlFieldInfo *field) +{ + switch ((*array_visitor)->type) + { + case BoolType: + return (*array_visitor)->bool_arr->Value(currArrayIndex()); + case IntType: + return getSigned(array_visitor, currArrayIndex()); + case UIntType: + return getUnsigned(array_visitor, currArrayIndex()); + case RealType: + return getReal(array_visitor, currArrayIndex()); + case DateType: + return (*array_visitor)->size == 32 ? (*array_visitor)->date32_arr->Value(currArrayIndex()) : (*array_visitor)->date64_arr->Value(currArrayIndex()); + case TimestampType: + return (*array_visitor)->timestamp_arr->Value(currArrayIndex()); + case TimeType: + return (*array_visitor)->size == 32 ? (*array_visitor)->time32_arr->Value(currArrayIndex()) : (*array_visitor)->time64_arr->Value(currArrayIndex()); + case DurationType: + return (*array_visitor)->duration_arr->Value(currArrayIndex()); + default: + { + double mydouble = 0.0; + auto scalar = getCurrView(field); + std::string scalarStr(scalar.data(), scalar.size()); + handleDeserializeOutcome(tokenDeserializer.deserialize(scalarStr.c_str(), mydouble), "real", scalarStr.c_str()); + return mydouble; + } + } +} + /** * @brief Gets a Boolean result for an ECL Row * @@ -1020,10 +1052,7 @@ double ParquetRowBuilder::getRealResult(const RtlFieldInfo *field) return p.doubleResult; } - if ((*array_visitor)->type == RealType) - return getReal(array_visitor, currArrayIndex()); - else - return getCurrIntValue(field); + return getCurrRealValue(field); } /** diff --git a/plugins/parquet/parquetembed.hpp b/plugins/parquet/parquetembed.hpp index 9f1bb2015e0..7e233f53986 100644 --- a/plugins/parquet/parquetembed.hpp +++ b/plugins/parquet/parquetembed.hpp @@ -899,6 +899,7 @@ class ParquetRowBuilder : public CInterfaceOf const std::shared_ptr &getChunk(std::shared_ptr *column); std::string_view getCurrView(const RtlFieldInfo *field); __int64 getCurrIntValue(const RtlFieldInfo *field); + double getCurrRealValue(const RtlFieldInfo *field); void nextField(const RtlFieldInfo *field); void nextFromStruct(const RtlFieldInfo *field); void xpathOrName(StringBuffer &outXPath, const RtlFieldInfo *field) const;