This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new ef00dad680d [Fix](multi-catalog) Fix some undefined behaviors. (#38274)
ef00dad680d is described below
commit ef00dad680d1ec6da5e482c4c1a9503046b0ae2f
Author: Qi Chen <[email protected]>
AuthorDate: Wed Jul 24 16:14:34 2024 +0800
[Fix](multi-catalog) Fix some undefined behaviors. (#38274)
## Proposed changes
backport #37845
---
be/src/vec/exec/format/orc/vorc_reader.cpp | 4 ++--
.../exec/format/parquet/parquet_column_convert.h | 26 ++++++++++++----------
2 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/be/src/vec/exec/format/orc/vorc_reader.cpp
b/be/src/vec/exec/format/orc/vorc_reader.cpp
index 16909f0023a..49430471c9d 100644
--- a/be/src/vec/exec/format/orc/vorc_reader.cpp
+++ b/be/src/vec/exec/format/orc/vorc_reader.cpp
@@ -1586,7 +1586,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();
@@ -1656,7 +1656,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 bc6bc232327..551bf7e14ed 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<char*>(&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<char*>(&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<DecimalType&>(data[start_idx + i]);
v = (DecimalType)value;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]