You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/01/23 13:40:53 UTC

[doris] branch branch-1.2-lts updated (a23773393e -> e23788e0a7)

This is an automated email from the ASF dual-hosted git repository.

morningman pushed a change to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


    from a23773393e [regression](external p2) cherry pick external table p2 case from master (#16134)
     new fce353ddaa [Bug](predicate) add double predicate creator (#15762)
     new 2001689b1d [fix](planner) move join reorder to the single node planner (#15817)
     new e23788e0a7 [Chore](build) enable -Wextra and remove some -Wno (#15760)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 be/CMakeLists.txt                                  | 16 +++-------
 be/src/exec/arrow/arrow_reader.cpp                 |  2 +-
 be/src/exec/decompressor.cpp                       |  2 +-
 be/src/exec/plain_text_line_reader.cpp             |  2 +-
 .../schema_scanner/schema_charsets_scanner.cpp     |  3 +-
 be/src/http/action/pprof_actions.cpp               | 12 +++++---
 be/src/olap/column_vector.cpp                      |  1 -
 be/src/olap/delta_writer.h                         |  4 +--
 be/src/olap/predicate_creator.h                    | 15 ++++++++-
 .../olap/rowset/segment_v2/bitmap_index_reader.cpp |  4 +--
 be/src/olap/rowset/segment_v2/bloom_filter.cpp     |  2 +-
 be/src/olap/rowset/segment_v2/column_reader.cpp    | 36 ++++++++++------------
 .../rowset/segment_v2/indexed_column_reader.cpp    |  2 +-
 be/src/olap/tablet.cpp                             |  4 +--
 be/src/runtime/decimalv2_value.cpp                 |  1 -
 be/src/util/bfd_parser.cpp                         |  9 ++++--
 be/src/util/block_compression.cpp                  |  2 +-
 be/src/util/frame_of_reference_coding.cpp          |  5 +--
 be/src/util/pprof_utils.cpp                        | 11 ++++---
 be/src/util/zip_util.cpp                           |  4 ---
 be/src/vec/data_types/data_type_decimal.h          |  2 +-
 be/src/vec/exec/vset_operation_node.cpp            |  2 +-
 be/src/vec/exec/vset_operation_node.h              |  1 -
 be/src/vec/functions/if.cpp                        |  1 -
 be/src/vec/olap/vertical_merge_iterator.cpp        |  1 -
 be/src/vec/olap/vgeneric_iterators.cpp             |  2 --
 be/test/olap/aggregate_func_test.cpp               |  1 -
 be/test/vec/function/function_test_util.cpp        |  2 +-
 .../utils/arrow_column_to_doris_column_test.cpp    |  1 -
 .../java/org/apache/doris/analysis/SelectStmt.java |  6 +---
 .../apache/doris/planner/SingleNodePlanner.java    |  5 +++
 .../limit/sql/withOrderBy.out}                     | 13 ++++++--
 .../suites/query_p0/limit/sql/withOrderBy.sql      |  4 +++
 33 files changed, 95 insertions(+), 83 deletions(-)
 copy regression-test/data/{brown_p2/sql/dataTransferRate.out => query_p0/limit/sql/withOrderBy.out} (58%)
 create mode 100644 regression-test/suites/query_p0/limit/sql/withOrderBy.sql


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[doris] 03/03: [Chore](build) enable -Wextra and remove some -Wno (#15760)

Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit e23788e0a7dd9464fd85902c39663d0a83b7e5d1
Author: Pxl <px...@qq.com>
AuthorDate: Sun Jan 15 10:40:35 2023 +0800

    [Chore](build) enable -Wextra and remove some -Wno (#15760)
    
    enable -Wextra and remove some -Wno
---
 be/CMakeLists.txt                                  | 16 +++-------
 be/src/exec/arrow/arrow_reader.cpp                 |  2 +-
 be/src/exec/decompressor.cpp                       |  2 +-
 be/src/exec/plain_text_line_reader.cpp             |  2 +-
 .../schema_scanner/schema_charsets_scanner.cpp     |  3 +-
 be/src/http/action/pprof_actions.cpp               | 12 +++++---
 be/src/olap/column_vector.cpp                      |  1 -
 be/src/olap/delta_writer.h                         |  4 +--
 .../olap/rowset/segment_v2/bitmap_index_reader.cpp |  4 +--
 be/src/olap/rowset/segment_v2/bloom_filter.cpp     |  2 +-
 be/src/olap/rowset/segment_v2/column_reader.cpp    | 36 ++++++++++------------
 .../rowset/segment_v2/indexed_column_reader.cpp    |  2 +-
 be/src/olap/tablet.cpp                             |  4 +--
 be/src/runtime/decimalv2_value.cpp                 |  1 -
 be/src/util/bfd_parser.cpp                         |  9 ++++--
 be/src/util/block_compression.cpp                  |  2 +-
 be/src/util/frame_of_reference_coding.cpp          |  5 +--
 be/src/util/pprof_utils.cpp                        | 11 ++++---
 be/src/util/zip_util.cpp                           |  4 ---
 be/src/vec/data_types/data_type_decimal.h          |  2 +-
 be/src/vec/exec/vset_operation_node.cpp            |  2 +-
 be/src/vec/exec/vset_operation_node.h              |  1 -
 be/src/vec/functions/if.cpp                        |  1 -
 be/src/vec/olap/vertical_merge_iterator.cpp        |  1 -
 be/src/vec/olap/vgeneric_iterators.cpp             |  2 --
 be/test/olap/aggregate_func_test.cpp               |  1 -
 be/test/vec/function/function_test_util.cpp        |  2 +-
 .../utils/arrow_column_to_doris_column_test.cpp    |  1 -
 28 files changed, 60 insertions(+), 75 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index cf51ddc492..aedb3a97b7 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -423,12 +423,13 @@ check_function_exists(sched_getcpu HAVE_SCHED_GETCPU)
 
 # compiler flags that are common across debug/release builds
 #  -Wall: Enable all warnings.
-#  -Wno-sign-compare: suppress warnings for comparison between signed and unsigned
 #    integers
 #  -pthread: enable multithreaded malloc
 #  -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG: enable nanosecond precision for boost
 #  -fno-omit-frame-pointers: Keep frame pointer for functions in register
-set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall -Wno-sign-compare -pthread -Werror")
+set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -g -Wall -Wextra -pthread -Werror")
+# TODO: resolve and remove those wno
+set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-implicit-fallthrough -Wno-sign-compare")
 set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -fstrict-aliasing -fno-omit-frame-pointer")
 set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -std=gnu++17 -D__STDC_FORMAT_MACROS")
 set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG")
@@ -452,9 +453,7 @@ endfunction()
 
 # In terms of performance, mold> lld> gold> ld
 set(CUSTUM_LINKER_COMMAND "ld")
-# TODO: mold will link fail on thirdparty brpc now, waiting for investigation.
-# TRY_TO_CHANGE_LINKER("mold" "mold")
-
+TRY_TO_CHANGE_LINKER("mold" "mold")
 TRY_TO_CHANGE_LINKER("lld" "LLD")
 TRY_TO_CHANGE_LINKER("gold" "GNU gold")
 if (NOT CUSTUM_LINKER_COMMAND STREQUAL "ld")
@@ -493,7 +492,7 @@ if ("${CMAKE_BUILD_TARGET_ARCH}" STREQUAL "x86" OR "${CMAKE_BUILD_TARGET_ARCH}"
         set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -mavx2")
     endif()
 endif()
-set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-attributes -DS2_USE_GFLAGS -DS2_USE_GLOG")
+set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DS2_USE_GFLAGS -DS2_USE_GLOG")
 
 if (WITH_MYSQL)
     set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DDORIS_WITH_MYSQL")
@@ -530,11 +529,6 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
     set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -faligned-new")
 endif()
 
-# For any gcc builds:
-#   -g: Enable symbols for profiler tools. Produce debugging information in the operating system’s native formt
-#   -Wno-unused-local-typedefs: Do not warn for local typedefs that are unused.
-set(CXX_GCC_FLAGS "${CXX_GCC_FLAGS} -g -Wno-unused-local-typedefs")
-
 if (USE_DWARF)
     set(CXX_GCC_FLAGS "${CXX_GCC_FLAGS} -gdwarf-5")
 endif()
diff --git a/be/src/exec/arrow/arrow_reader.cpp b/be/src/exec/arrow/arrow_reader.cpp
index 79e206649f..39e362205f 100644
--- a/be/src/exec/arrow/arrow_reader.cpp
+++ b/be/src/exec/arrow/arrow_reader.cpp
@@ -262,7 +262,7 @@ arrow::Result<std::shared_ptr<arrow::Buffer>> ArrowFile::Read(int64_t nbytes) {
     ARROW_RETURN_NOT_OK(bytes_read);
     // If bytes_read is equal with read_buf's capacity, we just assign
     if (bytes_read.ValueOrDie() == nbytes) {
-        return std::move(read_buf);
+        return read_buf;
     } else {
         return arrow::SliceBuffer(read_buf, 0, bytes_read.ValueOrDie());
     }
diff --git a/be/src/exec/decompressor.cpp b/be/src/exec/decompressor.cpp
index 5d7dee008e..5712c44179 100644
--- a/be/src/exec/decompressor.cpp
+++ b/be/src/exec/decompressor.cpp
@@ -67,7 +67,7 @@ GzipDecompressor::~GzipDecompressor() {
 }
 
 Status GzipDecompressor::init() {
-    _z_strm = {nullptr};
+    _z_strm = {};
     _z_strm.zalloc = Z_NULL;
     _z_strm.zfree = Z_NULL;
     _z_strm.opaque = Z_NULL;
diff --git a/be/src/exec/plain_text_line_reader.cpp b/be/src/exec/plain_text_line_reader.cpp
index 06d55dccd2..3c24a345b7 100644
--- a/be/src/exec/plain_text_line_reader.cpp
+++ b/be/src/exec/plain_text_line_reader.cpp
@@ -85,7 +85,7 @@ void PlainTextLineReader::close() {
 inline bool PlainTextLineReader::update_eof() {
     if (done()) {
         _eof = true;
-    } else if (_decompressor == nullptr && (_min_length >= 0 && _total_read_bytes >= _min_length)) {
+    } else if (_decompressor == nullptr && _total_read_bytes >= _min_length) {
         _eof = true;
     }
     return _eof;
diff --git a/be/src/exec/schema_scanner/schema_charsets_scanner.cpp b/be/src/exec/schema_scanner/schema_charsets_scanner.cpp
index 6621b10e1d..27772c85bf 100644
--- a/be/src/exec/schema_scanner/schema_charsets_scanner.cpp
+++ b/be/src/exec/schema_scanner/schema_charsets_scanner.cpp
@@ -17,7 +17,6 @@
 
 #include "exec/schema_scanner/schema_charsets_scanner.h"
 
-#include "runtime/primitive_type.h"
 #include "runtime/string_value.h"
 
 namespace doris {
@@ -32,7 +31,7 @@ SchemaScanner::ColumnDesc SchemaCharsetsScanner::_s_css_columns[] = {
 
 SchemaCharsetsScanner::CharsetStruct SchemaCharsetsScanner::_s_charsets[] = {
         {"utf8", "utf8_general_ci", "UTF-8 Unicode", 3},
-        {nullptr, nullptr, 0},
+        {nullptr, nullptr, nullptr, 0},
 };
 
 SchemaCharsetsScanner::SchemaCharsetsScanner()
diff --git a/be/src/http/action/pprof_actions.cpp b/be/src/http/action/pprof_actions.cpp
index 1cc5a43d33..c0f03f03bc 100644
--- a/be/src/http/action/pprof_actions.cpp
+++ b/be/src/http/action/pprof_actions.cpp
@@ -227,12 +227,16 @@ void CmdlineAction::handle(HttpRequest* req) {
         HttpChannel::send_reply(req, str);
         return;
     }
+
+    std::string str;
     char buf[1024];
-    // Ignore unused return value
-    if (fscanf(fp, "%1023s ", buf))
-        ;
+    if (fscanf(fp, "%1023s ", buf) == 1) {
+        str = buf;
+    } else {
+        str = "Unable to read file: /proc/self/cmdline";
+    }
+
     fclose(fp);
-    std::string str = buf;
 
     HttpChannel::send_reply(req, str);
 }
diff --git a/be/src/olap/column_vector.cpp b/be/src/olap/column_vector.cpp
index 8211bd9d1a..7ec51ca672 100644
--- a/be/src/olap/column_vector.cpp
+++ b/be/src/olap/column_vector.cpp
@@ -239,7 +239,6 @@ void ArrayColumnVectorBatch::put_item_ordinal(segment_v2::ordinal_t* ordinals, s
 }
 
 void ArrayColumnVectorBatch::get_offset_by_length(size_t start_idx, size_t size) {
-    DCHECK(start_idx >= 0);
     DCHECK(start_idx + size < _offsets->capacity());
 
     for (size_t i = start_idx; i < start_idx + size; ++i) {
diff --git a/be/src/olap/delta_writer.h b/be/src/olap/delta_writer.h
index dafd77a8f8..b7f3c0cf65 100644
--- a/be/src/olap/delta_writer.h
+++ b/be/src/olap/delta_writer.h
@@ -48,8 +48,8 @@ struct WriteRequest {
     // slots are in order of tablet's schema
     const std::vector<SlotDescriptor*>* slots;
     bool is_high_priority = false;
-    POlapTableSchemaParam ptable_schema_param;
-    int64_t index_id;
+    POlapTableSchemaParam ptable_schema_param = {};
+    int64_t index_id = 0;
 };
 
 // Writer for a particular (load, index, tablet).
diff --git a/be/src/olap/rowset/segment_v2/bitmap_index_reader.cpp b/be/src/olap/rowset/segment_v2/bitmap_index_reader.cpp
index eb108f8e8d..d916e51b05 100644
--- a/be/src/olap/rowset/segment_v2/bitmap_index_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/bitmap_index_reader.cpp
@@ -46,7 +46,7 @@ Status BitmapIndexIterator::seek_dictionary(const void* value, bool* exact_match
 }
 
 Status BitmapIndexIterator::read_bitmap(rowid_t ordinal, roaring::Roaring* result) {
-    DCHECK(0 <= ordinal && ordinal < _reader->bitmap_nums());
+    DCHECK(ordinal < _reader->bitmap_nums());
 
     size_t num_to_read = 1;
     std::unique_ptr<ColumnVectorBatch> cvb;
@@ -66,7 +66,7 @@ Status BitmapIndexIterator::read_bitmap(rowid_t ordinal, roaring::Roaring* resul
 }
 
 Status BitmapIndexIterator::read_union_bitmap(rowid_t from, rowid_t to, roaring::Roaring* result) {
-    DCHECK(0 <= from && from <= to && to <= _reader->bitmap_nums());
+    DCHECK(from <= to && to <= _reader->bitmap_nums());
 
     for (rowid_t pos = from; pos < to; pos++) {
         roaring::Roaring bitmap;
diff --git a/be/src/olap/rowset/segment_v2/bloom_filter.cpp b/be/src/olap/rowset/segment_v2/bloom_filter.cpp
index cbb5181ac5..e796ae7bf7 100644
--- a/be/src/olap/rowset/segment_v2/bloom_filter.cpp
+++ b/be/src/olap/rowset/segment_v2/bloom_filter.cpp
@@ -48,7 +48,7 @@ uint32_t BloomFilter::optimal_bit_num(uint64_t n, double fpp) {
     // ref parquet bloom_filter branch(BlockSplitBloomFilter.java)
     uint32_t num_bits = -8 * (double)n / log(1 - pow(fpp, 1.0 / 8));
     uint32_t max_bits = MAXIMUM_BYTES << 3;
-    if (num_bits > max_bits || num_bits < 0) {
+    if (num_bits > max_bits) {
         num_bits = max_bits;
     }
 
diff --git a/be/src/olap/rowset/segment_v2/column_reader.cpp b/be/src/olap/rowset/segment_v2/column_reader.cpp
index 4ce70b1b0d..67c37277a2 100644
--- a/be/src/olap/rowset/segment_v2/column_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/column_reader.cpp
@@ -501,28 +501,26 @@ Status ArrayFileColumnIterator::next_batch(size_t* n, ColumnBlockView* dst, bool
 
     // read item
     size_t item_size = ordinals[*n] - ordinals[0];
-    if (item_size >= 0) {
-        bool item_has_null = false;
-        ColumnVectorBatch* item_vector_batch = array_batch->elements();
-
-        bool rebuild_array_from0 = false;
-        if (item_vector_batch->capacity() < array_batch->item_offset(dst->current_offset() + *n)) {
-            item_vector_batch->resize(array_batch->item_offset(dst->current_offset() + *n));
-            rebuild_array_from0 = true;
-        }
-
-        ColumnBlock item_block = ColumnBlock(item_vector_batch, dst->pool());
-        ColumnBlockView item_view =
-                ColumnBlockView(&item_block, array_batch->item_offset(dst->current_offset()));
-        size_t real_read = item_size;
-        RETURN_IF_ERROR(_item_iterator->next_batch(&real_read, &item_view, &item_has_null));
-        DCHECK(item_size == real_read);
+    bool item_has_null = false;
+    ColumnVectorBatch* item_vector_batch = array_batch->elements();
 
-        size_t rebuild_start_offset = rebuild_array_from0 ? 0 : dst->current_offset();
-        size_t rebuild_size = rebuild_array_from0 ? dst->current_offset() + *n : *n;
-        array_batch->prepare_for_read(rebuild_start_offset, rebuild_size, item_has_null);
+    bool rebuild_array_from0 = false;
+    if (item_vector_batch->capacity() < array_batch->item_offset(dst->current_offset() + *n)) {
+        item_vector_batch->resize(array_batch->item_offset(dst->current_offset() + *n));
+        rebuild_array_from0 = true;
     }
 
+    ColumnBlock item_block = ColumnBlock(item_vector_batch, dst->pool());
+    ColumnBlockView item_view =
+            ColumnBlockView(&item_block, array_batch->item_offset(dst->current_offset()));
+    size_t real_read = item_size;
+    RETURN_IF_ERROR(_item_iterator->next_batch(&real_read, &item_view, &item_has_null));
+    DCHECK(item_size == real_read);
+
+    size_t rebuild_start_offset = rebuild_array_from0 ? 0 : dst->current_offset();
+    size_t rebuild_size = rebuild_array_from0 ? dst->current_offset() + *n : *n;
+    array_batch->prepare_for_read(rebuild_start_offset, rebuild_size, item_has_null);
+
     dst->advance(*n);
     return Status::OK();
 }
diff --git a/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp b/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp
index 6bcf6055d9..bac4bc4567 100644
--- a/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp
@@ -123,7 +123,7 @@ Status IndexedColumnIterator::_read_data_page(const PagePointer& pp) {
 }
 
 Status IndexedColumnIterator::seek_to_ordinal(ordinal_t idx) {
-    DCHECK(idx >= 0 && idx <= _reader->num_values());
+    DCHECK(idx <= _reader->num_values());
 
     if (!_reader->support_ordinal_seek()) {
         return Status::NotSupported("no ordinal index");
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index 2b61445b66..f039bf96f7 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -1976,8 +1976,8 @@ Status Tablet::lookup_row_key(const Slice& encoded_key, const RowsetIdUnorderedS
             return s;
         }
         loc.rowset_id = rs.first->rowset_id();
-        if (version >= 0 && _tablet_meta->delete_bitmap().contains_agg(
-                                    {loc.rowset_id, loc.segment_id, version}, loc.row_id)) {
+        if (_tablet_meta->delete_bitmap().contains_agg({loc.rowset_id, loc.segment_id, version},
+                                                       loc.row_id)) {
             // if has sequence col, we continue to compare the sequence_id of
             // all rowsets, util we find an existing key.
             if (_schema->has_sequence_col()) {
diff --git a/be/src/runtime/decimalv2_value.cpp b/be/src/runtime/decimalv2_value.cpp
index adae08efd1..3d7f56c047 100644
--- a/be/src/runtime/decimalv2_value.cpp
+++ b/be/src/runtime/decimalv2_value.cpp
@@ -243,7 +243,6 @@ static std::pair<double, double> quadratic_equation_naive(__uint128_t a, __uint1
     __uint128_t dis = b * b - 4 * a * c;
     // assert(dis >= 0);
     // not handling complex root
-    if (dis < 0) return std::make_pair(0, 0);
     double sqrtdis = std::sqrt(static_cast<double>(dis));
     double a_r = static_cast<double>(a);
     double b_r = static_cast<double>(b);
diff --git a/be/src/util/bfd_parser.cpp b/be/src/util/bfd_parser.cpp
index 4486ce26b0..98f0a46d62 100644
--- a/be/src/util/bfd_parser.cpp
+++ b/be/src/util/bfd_parser.cpp
@@ -102,9 +102,12 @@ BfdParser* BfdParser::create() {
     }
 
     char prog_name[1024];
-    // Ignore unused return value
-    if (fscanf(file, "%1023s ", prog_name))
-        ;
+
+    if (fscanf(file, "%1023s ", prog_name) != 1) {
+        fclose(file);
+        return nullptr;
+    }
+
     fclose(file);
     std::unique_ptr<BfdParser> parser(new BfdParser(prog_name));
     if (parser->parse()) {
diff --git a/be/src/util/block_compression.cpp b/be/src/util/block_compression.cpp
index 821636c4f9..4ff091b677 100644
--- a/be/src/util/block_compression.cpp
+++ b/be/src/util/block_compression.cpp
@@ -817,7 +817,7 @@ public:
     ~GzipBlockCompression() override = default;
 
     Status decompress(const Slice& input, Slice* output) override {
-        z_stream z_strm = {nullptr};
+        z_stream z_strm = {};
         z_strm.zalloc = Z_NULL;
         z_strm.zfree = Z_NULL;
         z_strm.opaque = Z_NULL;
diff --git a/be/src/util/frame_of_reference_coding.cpp b/be/src/util/frame_of_reference_coding.cpp
index 5ab334b3c3..0e7bb57b64 100644
--- a/be/src/util/frame_of_reference_coding.cpp
+++ b/be/src/util/frame_of_reference_coding.cpp
@@ -235,9 +235,6 @@ bool ForDecoder<T>::init() {
     _last_frame_size = _max_frame_size - (_max_frame_size * _frame_count - _values_num);
 
     size_t bit_width_offset = _buffer_len - 5 - _frame_count * 2;
-    if (bit_width_offset < 0) {
-        return false;
-    }
 
     // read _storage_formats, bit_widths and compute frame_offsets
     u_int32_t frame_start_offset = 0;
@@ -398,7 +395,7 @@ bool ForDecoder<T>::get_batch(T* val, size_t count) {
 
 template <typename T>
 bool ForDecoder<T>::skip(int32_t skip_num) {
-    if (_current_index + skip_num >= _values_num || _current_index + skip_num < 0) {
+    if (_current_index + skip_num >= _values_num) {
         return false;
     }
     _current_index = _current_index + skip_num;
diff --git a/be/src/util/pprof_utils.cpp b/be/src/util/pprof_utils.cpp
index 51c0486f92..8fc58410c8 100644
--- a/be/src/util/pprof_utils.cpp
+++ b/be/src/util/pprof_utils.cpp
@@ -66,12 +66,15 @@ Status PprofUtils::get_self_cmdline(std::string* cmd) {
         return Status::InternalError("Unable to open file: /proc/self/cmdline");
     }
     char buf[1024];
-    // Ignore unused return value
-    if (fscanf(fp, "%1023s ", buf))
-        ;
+
+    Status res = Status::OK();
+
+    if (fscanf(fp, "%1023s ", buf) != 1) {
+        res = Status::InternalError("get_self_cmdline read buffer failed");
+    }
     fclose(fp);
     *cmd = buf;
-    return Status::OK();
+    return res;
 }
 
 Status PprofUtils::get_readable_profile(const std::string& file_or_content, bool is_file,
diff --git a/be/src/util/zip_util.cpp b/be/src/util/zip_util.cpp
index 901230e5cb..95e4d686fc 100644
--- a/be/src/util/zip_util.cpp
+++ b/be/src/util/zip_util.cpp
@@ -123,10 +123,6 @@ Status ZipFile::extract_file(const std::string& target_path) {
     size_t size = 0;
     do {
         size = unzReadCurrentFile(_zip_file, (voidp)file_data.get(), file_size);
-        if (size < 0) {
-            return Status::IOError("unzip file {} failed", file_name);
-        }
-
         RETURN_IF_ERROR(wfile->append(Slice(file_data.get(), size)));
     } while (size > 0);
 
diff --git a/be/src/vec/data_types/data_type_decimal.h b/be/src/vec/data_types/data_type_decimal.h
index ef3d58758a..ffc0564687 100644
--- a/be/src/vec/data_types/data_type_decimal.h
+++ b/be/src/vec/data_types/data_type_decimal.h
@@ -123,7 +123,7 @@ public:
             LOG(FATAL) << fmt::format("Precision {} is out of bounds", precision);
         }
 
-        if (UNLIKELY(scale < 0 || static_cast<UInt32>(scale) > max_precision())) {
+        if (UNLIKELY(static_cast<UInt32>(scale) > max_precision())) {
             LOG(FATAL) << fmt::format("Scale {} is out of bounds", scale);
         }
     }
diff --git a/be/src/vec/exec/vset_operation_node.cpp b/be/src/vec/exec/vset_operation_node.cpp
index 769e125524..1324c5f7d5 100644
--- a/be/src/vec/exec/vset_operation_node.cpp
+++ b/be/src/vec/exec/vset_operation_node.cpp
@@ -430,4 +430,4 @@ void VSetOperationNode::release_mem() {
 }
 
 } // namespace vectorized
-} // namespace doris
\ No newline at end of file
+} // namespace doris
diff --git a/be/src/vec/exec/vset_operation_node.h b/be/src/vec/exec/vset_operation_node.h
index 473042940a..902f19efa4 100644
--- a/be/src/vec/exec/vset_operation_node.h
+++ b/be/src/vec/exec/vset_operation_node.h
@@ -178,7 +178,6 @@ struct HashTableProbe {
 
     Status mark_data_in_hashtable(HashTableContext& hash_table_ctx) {
         using KeyGetter = typename HashTableContext::State;
-        using Mapped = typename HashTableContext::Mapped;
 
         KeyGetter key_getter(_probe_raw_ptrs, _operation_node->_probe_key_sz, nullptr);
 
diff --git a/be/src/vec/functions/if.cpp b/be/src/vec/functions/if.cpp
index 0d36f462ae..031ec30118 100644
--- a/be/src/vec/functions/if.cpp
+++ b/be/src/vec/functions/if.cpp
@@ -206,7 +206,6 @@ public:
         auto call = [&](const auto& types) -> bool {
             using Types = std::decay_t<decltype(types)>;
             using T0 = typename Types::LeftType;
-            using T1 = typename Types::RightType;
             using result_type = typename Types::LeftType;
 
             // for doris, args type and return type must be sanme beacause of type cast has already done before, so here just need one type;
diff --git a/be/src/vec/olap/vertical_merge_iterator.cpp b/be/src/vec/olap/vertical_merge_iterator.cpp
index 54a51fdee5..2b9a7405a6 100644
--- a/be/src/vec/olap/vertical_merge_iterator.cpp
+++ b/be/src/vec/olap/vertical_merge_iterator.cpp
@@ -256,7 +256,6 @@ void VerticalMergeIteratorContext::copy_rows(Block* block, bool advanced) {
 
     // copy a row to dst block column by column
     size_t start = _index_in_block - _cur_batch_num + 1 - advanced;
-    DCHECK(start >= 0);
 
     for (size_t i = 0; i < _ori_return_cols; ++i) {
         auto& s_col = src.get_by_position(i);
diff --git a/be/src/vec/olap/vgeneric_iterators.cpp b/be/src/vec/olap/vgeneric_iterators.cpp
index f70b93d576..13a9c06dd5 100644
--- a/be/src/vec/olap/vgeneric_iterators.cpp
+++ b/be/src/vec/olap/vgeneric_iterators.cpp
@@ -137,7 +137,6 @@ void VMergeIteratorContext::copy_rows(Block* block, bool advanced) {
 
     // copy a row to dst block column by column
     size_t start = _index_in_block - _cur_batch_num + 1 - advanced;
-    DCHECK(start >= 0);
 
     for (size_t i = 0; i < _num_columns; ++i) {
         auto& s_col = src.get_by_position(i);
@@ -158,7 +157,6 @@ void VMergeIteratorContext::copy_rows(BlockView* view, bool advanced) {
         return;
     }
     size_t start = _index_in_block - _cur_batch_num + 1 - advanced;
-    DCHECK(start >= 0);
 
     const auto& tmp_pre_ctx_same_bit = get_pre_ctx_same();
     for (size_t i = 0; i < _cur_batch_num; ++i) {
diff --git a/be/test/olap/aggregate_func_test.cpp b/be/test/olap/aggregate_func_test.cpp
index 687048419b..8cb1cc0120 100644
--- a/be/test/olap/aggregate_func_test.cpp
+++ b/be/test/olap/aggregate_func_test.cpp
@@ -311,7 +311,6 @@ void test_replace() {
 
 template <FieldType field_type>
 void test_replace_string() {
-    using CppType = typename CppTypeTraits<field_type>::CppType;
     constexpr size_t string_field_size = sizeof(bool) + sizeof(Slice);
 
     char dst[string_field_size];
diff --git a/be/test/vec/function/function_test_util.cpp b/be/test/vec/function/function_test_util.cpp
index 0dbea78d02..ae35124e66 100644
--- a/be/test/vec/function/function_test_util.cpp
+++ b/be/test/vec/function/function_test_util.cpp
@@ -51,7 +51,7 @@ uint64_t str_to_datetime_v2(std::string datetime_str, std::string datetime_forma
 size_t type_index_to_data_type(const std::vector<AnyType>& input_types, size_t index,
                                ut_type::UTDataTypeDesc& ut_desc, DataTypePtr& type) {
     doris_udf::FunctionContext::TypeDesc& desc = ut_desc.type_desc;
-    if (index < 0 || index >= input_types.size()) {
+    if (index >= input_types.size()) {
         return -1;
     }
 
diff --git a/be/test/vec/utils/arrow_column_to_doris_column_test.cpp b/be/test/vec/utils/arrow_column_to_doris_column_test.cpp
index 608775ef13..fda70edd56 100644
--- a/be/test/vec/utils/arrow_column_to_doris_column_test.cpp
+++ b/be/test/vec/utils/arrow_column_to_doris_column_test.cpp
@@ -389,7 +389,6 @@ void test_arrow_to_decimal_column(std::shared_ptr<arrow::Decimal128Type> type,
 template <bool is_nullable>
 void test_decimalv2(std::shared_ptr<arrow::Decimal128Type> type,
                     const std::vector<std::string>& test_cases, size_t num_elements) {
-    using ArrowCppType = typename arrow::TypeTraits<arrow::Decimal128Type>::CType;
     size_t counter = 0;
     auto pt = arrow_type_to_primitive_type(type->id());
     ASSERT_NE(pt, INVALID_TYPE);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[doris] 02/03: [fix](planner) move join reorder to the single node planner (#15817)

Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 2001689b1d6bf467c7cefce409487e62eeebfa8a
Author: AKIRA <33...@users.noreply.github.com>
AuthorDate: Fri Jan 13 19:42:12 2023 +0800

    [fix](planner) move join reorder to the single node planner (#15817)
    
    Reorder in analyze phase would produce a stmt which its corresponding SQL could not be analyzed correctly and cause an analyze exception that may be happened in the stmt rewrite, since the rewriter will reset and reanalyze the rewritten stmt.
---
 fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java  | 6 +-----
 .../src/main/java/org/apache/doris/planner/SingleNodePlanner.java   | 5 +++++
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index fbb89c0fca..2548136966 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -569,10 +569,6 @@ public class SelectStmt extends QueryStmt {
         if (needToSql) {
             sqlString = toSql();
         }
-        if (analyzer.enableStarJoinReorder()) {
-            LOG.debug("use old reorder logical in select stmt");
-            reorderTable(analyzer);
-        }
 
         resolveInlineViewRefs(analyzer);
 
@@ -764,7 +760,7 @@ public class SelectStmt extends QueryStmt {
         }
     }
 
-    protected void reorderTable(Analyzer analyzer) throws AnalysisException {
+    public void reorderTable(Analyzer analyzer) throws AnalysisException {
         List<Pair<TableRef, Long>> candidates = Lists.newArrayList();
         ArrayList<TableRef> originOrderBackUp = Lists.newArrayList(fromClause.getTableRefs());
         // New pair of table ref and row count
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
index 5ec1180b30..e6ab97d2a4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
@@ -1116,6 +1116,11 @@ public class SingleNodePlanner {
             return createConstantSelectPlan(selectStmt, analyzer);
         }
 
+        if (analyzer.enableStarJoinReorder()) {
+            LOG.debug("use old reorder logical in select stmt");
+            selectStmt.reorderTable(analyzer);
+        }
+
         // Slot materialization:
         // We need to mark all slots as materialized that are needed during the execution
         // of selectStmt, and we need to do that prior to creating plans for the TableRefs


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[doris] 01/03: [Bug](predicate) add double predicate creator (#15762)

Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit fce353ddaae31b2d3cb41bcdc021b87084614fd5
Author: AlexYue <yj...@gmail.com>
AuthorDate: Fri Jan 13 18:34:09 2023 +0800

    [Bug](predicate) add double predicate creator (#15762)
    
    Add one double predicator the same as integer predicate creator.
---
 be/src/olap/predicate_creator.h                           | 15 ++++++++++++++-
 regression-test/data/query_p0/limit/sql/withOrderBy.out   | 13 +++++++++++++
 regression-test/suites/query_p0/limit/sql/withOrderBy.sql |  4 ++++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/be/src/olap/predicate_creator.h b/be/src/olap/predicate_creator.h
index 12d10e109f..95fd13f8a2 100644
--- a/be/src/olap/predicate_creator.h
+++ b/be/src/olap/predicate_creator.h
@@ -58,7 +58,14 @@ public:
 private:
     static CppType convert(const std::string& condition) {
         CppType value = 0;
-        std::from_chars(condition.data(), condition.data() + condition.size(), value);
+        // because std::from_chars can't compile on macOS
+        if constexpr (std::is_same_v<CppType, double>) {
+            value = std::stod(condition, nullptr);
+        } else if constexpr (std::is_same_v<CppType, float>) {
+            value = std::stof(condition, nullptr);
+        } else {
+            std::from_chars(condition.data(), condition.data() + condition.size(), value);
+        }
         return value;
     }
 };
@@ -157,6 +164,12 @@ inline std::unique_ptr<PredicateCreator<ConditionType>> get_creator(const FieldT
     case OLAP_FIELD_TYPE_LARGEINT: {
         return std::make_unique<IntegerPredicateCreator<TYPE_LARGEINT, PT, ConditionType>>();
     }
+    case OLAP_FIELD_TYPE_FLOAT: {
+        return std::make_unique<IntegerPredicateCreator<TYPE_FLOAT, PT, ConditionType>>();
+    }
+    case OLAP_FIELD_TYPE_DOUBLE: {
+        return std::make_unique<IntegerPredicateCreator<TYPE_DOUBLE, PT, ConditionType>>();
+    }
     case OLAP_FIELD_TYPE_DECIMAL: {
         return std::make_unique<CustomPredicateCreator<TYPE_DECIMALV2, PT, ConditionType>>(
                 [](const std::string& condition) {
diff --git a/regression-test/data/query_p0/limit/sql/withOrderBy.out b/regression-test/data/query_p0/limit/sql/withOrderBy.out
new file mode 100644
index 0000000000..70772b5fd7
--- /dev/null
+++ b/regression-test/data/query_p0/limit/sql/withOrderBy.out
@@ -0,0 +1,13 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !withOrderBy --
+1.05
+1.2
+1.27
+1.43
+1.48
+1.63
+1.69
+1.87
+2.02
+2.04
+
diff --git a/regression-test/suites/query_p0/limit/sql/withOrderBy.sql b/regression-test/suites/query_p0/limit/sql/withOrderBy.sql
new file mode 100644
index 0000000000..96ba0d81dd
--- /dev/null
+++ b/regression-test/suites/query_p0/limit/sql/withOrderBy.sql
@@ -0,0 +1,4 @@
+SELECT ref_0.`supplycost`
+FROM regression_test_query_p0_limit.tpch_tiny_partsupp AS ref_0
+ORDER BY ref_0.`supplycost`
+LIMIT 10;
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org