Skip to content

Commit 1e6582e

Browse files
committed
all
1 parent 7f5ba43 commit 1e6582e

File tree

14 files changed

+209
-40
lines changed

14 files changed

+209
-40
lines changed

be/src/pipeline/exec/hashjoin_build_sink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ Status HashJoinBuildSinkOperatorX::sink(RuntimeState* state, vectorized::Block*
569569
if (local_state._build_side_mutable_block.empty()) {
570570
auto tmp_build_block = vectorized::VectorizedUtils::create_empty_columnswithtypename(
571571
_child->row_desc());
572-
tmp_build_block = *(tmp_build_block.create_same_struct_block(1, false));
572+
tmp_build_block = *(tmp_build_block.create_same_struct_block_with_type(1));
573573
local_state._build_col_ids.resize(_build_expr_ctxs.size());
574574
RETURN_IF_ERROR(local_state._do_evaluate(tmp_build_block, local_state._build_expr_ctxs,
575575
*local_state._build_expr_call_timer,

be/src/vec/columns/column.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ namespace doris::vectorized {
6161

6262
class Arena;
6363
class ColumnSorter;
64+
class IDataType;
6465

6566
using EqualFlags = std::vector<uint8_t>;
6667
using EqualRange = std::pair<int, int>;
68+
using DataTypePtr = std::shared_ptr<const IDataType>;
6769

6870
/// Declares interface to store columns in memory.
6971
class IColumn : public COW<IColumn> {
@@ -308,6 +310,15 @@ class IColumn : public COW<IColumn> {
308310
}
309311
}
310312

313+
/// for ColumnVector with type date/datetime, the default value depend on data type.
314+
virtual void insert_default_with_type(DataTypePtr type) { insert_default(); }
315+
316+
void insert_many_defaults_with_type(size_t length, DataTypePtr type) {
317+
for (size_t i = 0; i < length; ++i) {
318+
insert_default_with_type(type);
319+
}
320+
}
321+
311322
/** Removes last n elements.
312323
* Is used to support exception-safety of several operations.
313324
* For example, sometimes insertion should be reverted if we catch an exception during operation processing.

be/src/vec/columns/column_nullable.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ class ColumnNullable final : public COWHelper<IColumn, ColumnNullable>, public N
259259
_need_update_has_null = false;
260260
}
261261

262+
void insert_default_with_type(DataTypePtr type) override {
263+
get_nested_column().insert_default_with_type(type);
264+
get_null_map_data().push_back(1);
265+
_has_null = true;
266+
_need_update_has_null = false;
267+
}
268+
262269
void insert_many_defaults(size_t length) override {
263270
get_nested_column().insert_many_defaults(length);
264271
get_null_map_data().resize_fill(get_null_map_data().size() + length, 1);

be/src/vec/columns/column_struct.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ void ColumnStruct::insert_default() {
160160
}
161161
}
162162

163+
void ColumnStruct::insert_default_with_type(DataTypePtr type) {
164+
for (auto& column : columns) {
165+
column->insert_default_with_type(type);
166+
}
167+
}
168+
163169
void ColumnStruct::pop_back(size_t n) {
164170
for (auto& column : columns) {
165171
column->pop_back(n);

be/src/vec/columns/column_struct.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class ColumnStruct final : public COWHelper<IColumn, ColumnStruct> {
115115
void insert(const Field& x) override;
116116
void insert_from(const IColumn& src_, size_t n) override;
117117
void insert_default() override;
118+
void insert_default_with_type(DataTypePtr type) override;
118119
void pop_back(size_t n) override;
119120
StringRef serialize_value_into_arena(size_t n, Arena& arena, char const*& begin) const override;
120121
const char* deserialize_and_insert_from_arena(const char* pos) override;

be/src/vec/columns/column_vector.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <ostream>
2828
#include <string>
2929

30+
#include "util/binary_cast.hpp"
3031
#include "util/hash_util.hpp"
3132
#include "util/simd/bits.h"
3233
#include "vec/columns/column_impl.h"
@@ -40,6 +41,7 @@
4041
#include "vec/core/sort_block.h"
4142
#include "vec/core/types.h"
4243
#include "vec/data_types/data_type.h"
44+
#include "vec/runtime/vdatetime_value.h"
4345

4446
namespace doris::vectorized {
4547

@@ -505,6 +507,19 @@ void ColumnVector<T>::replace_column_null_data(const uint8_t* __restrict null_ma
505507
}
506508
}
507509

510+
template <typename T>
511+
void ColumnVector<T>::insert_default_with_type(DataTypePtr type) {
512+
if (WhichDataType(type).is_date_or_datetime()) {
513+
data.push_back(binary_cast<VecDateTimeValue, Int64>(VecDateTimeValue::DEFAULT_VALUE));
514+
} else if (WhichDataType(type).is_date_v2()) {
515+
data.push_back(DateV2Value<DateV2ValueType>::DEFAULT_VALUE.to_date_int_val());
516+
} else if (WhichDataType(type).is_date_time_v2()) {
517+
data.push_back(DateV2Value<DateTimeV2ValueType>::DEFAULT_VALUE.to_date_int_val());
518+
} else {
519+
insert_default();
520+
}
521+
}
522+
508523
/// Explicit template instantiations - to avoid code bloat in headers.
509524
template class ColumnVector<UInt8>;
510525
template class ColumnVector<UInt16>;

be/src/vec/columns/column_vector.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,9 @@
5353

5454
class SipHash;
5555

56-
namespace doris {
57-
namespace vectorized {
56+
namespace doris::vectorized {
5857
class Arena;
5958
class ColumnSorter;
60-
} // namespace vectorized
61-
} // namespace doris
62-
63-
namespace doris::vectorized {
6459

6560
/** Stuff for comparing numbers.
6661
* Integer values are compared as usual.
@@ -241,6 +236,8 @@ class ColumnVector final : public COWHelper<IColumn, ColumnVector<T>> {
241236

242237
void insert_default() override { data.push_back(T()); }
243238

239+
void insert_default_with_type(DataTypePtr type) override;
240+
244241
void insert_many_defaults(size_t length) override {
245242
size_t old_size = data.size();
246243
data.resize(old_size + length);

be/src/vec/core/block.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,16 @@ std::unique_ptr<Block> Block::create_same_struct_block(size_t size, bool is_rese
11931193
return temp_block;
11941194
}
11951195

1196+
std::unique_ptr<Block> Block::create_same_struct_block_with_type(size_t size) const {
1197+
auto temp_block = Block::create_unique();
1198+
for (const auto& d : data) {
1199+
auto column = d.type->create_column();
1200+
column->insert_many_defaults_with_type(size, d.type);
1201+
temp_block->insert({std::move(column), d.type, d.name});
1202+
}
1203+
return temp_block;
1204+
}
1205+
11961206
void Block::shrink_char_type_column_suffix_zero(const std::vector<size_t>& char_type_idx) {
11971207
for (auto idx : char_type_idx) {
11981208
if (idx < data.size()) {

be/src/vec/core/block.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ class Block {
312312
Status deserialize(const PBlock& pblock);
313313

314314
std::unique_ptr<Block> create_same_struct_block(size_t size, bool is_reserve = false) const;
315+
// only used for hashjoin build side to mock a row into block.
316+
std::unique_ptr<Block> create_same_struct_block_with_type(size_t size) const;
315317

316318
/** Compares (*this) n-th row and rhs m-th row.
317319
* Returns negative number, 0, or positive number (*this) n-th row is less, equal, greater than rhs m-th row respectively.

0 commit comments

Comments
 (0)