diff --git a/be/src/vec/exec/format/orc/vorc_reader.cpp b/be/src/vec/exec/format/orc/vorc_reader.cpp index aba1511c854496..9c016a4565e4e8 100644 --- a/be/src/vec/exec/format/orc/vorc_reader.cpp +++ b/be/src/vec/exec/format/orc/vorc_reader.cpp @@ -1583,7 +1583,7 @@ Status OrcReader::get_next_block_impl(Block* block, size_t* read_rows, bool* eof _decimal_scale_params_index = 0; try { rr = _row_reader->nextBatch(*_batch, block); - if (rr == 0) { + if (rr == 0 || _batch->numElements == 0) { *eof = true; *read_rows = 0; return Status::OK(); @@ -1653,7 +1653,7 @@ Status OrcReader::get_next_block_impl(Block* block, size_t* read_rows, bool* eof _decimal_scale_params_index = 0; try { rr = _row_reader->nextBatch(*_batch, block); - if (rr == 0) { + if (rr == 0 || _batch->numElements == 0) { *eof = true; *read_rows = 0; return Status::OK(); diff --git a/be/src/vec/exec/format/parquet/parquet_column_convert.h b/be/src/vec/exec/format/parquet/parquet_column_convert.h index bc6bc2323275cf..551bf7e14edbc8 100644 --- a/be/src/vec/exec/format/parquet/parquet_column_convert.h +++ b/be/src/vec/exec/format/parquet/parquet_column_convert.h @@ -408,18 +408,20 @@ class StringToDecimal : public PhysicalToLogicalConverter { // When Decimal in parquet is stored in byte arrays, binary and fixed, // the unscaled number must be encoded as two's complement using big-endian byte order. ValueCopyType value = 0; - memcpy(reinterpret_cast(&value), buf + offset[i - 1], len); - value = BitUtil::big_endian_to_host(value); - value = value >> ((sizeof(value) - len) * 8); - if constexpr (ScaleType == DecimalScaleParams::SCALE_UP) { - value *= scale_params.scale_factor; - } else if constexpr (ScaleType == DecimalScaleParams::SCALE_DOWN) { - value /= scale_params.scale_factor; - } else if constexpr (ScaleType == DecimalScaleParams::NO_SCALE) { - // do nothing - } else { - LOG(FATAL) << "__builtin_unreachable"; - __builtin_unreachable(); + if (len > 0) { + memcpy(reinterpret_cast(&value), buf + offset[i - 1], len); + value = BitUtil::big_endian_to_host(value); + value = value >> ((sizeof(value) - len) * 8); + if constexpr (ScaleType == DecimalScaleParams::SCALE_UP) { + value *= scale_params.scale_factor; + } else if constexpr (ScaleType == DecimalScaleParams::SCALE_DOWN) { + value /= scale_params.scale_factor; + } else if constexpr (ScaleType == DecimalScaleParams::NO_SCALE) { + // do nothing + } else { + LOG(FATAL) << "__builtin_unreachable"; + __builtin_unreachable(); + } } auto& v = reinterpret_cast(data[start_idx + i]); v = (DecimalType)value;