You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by xu...@apache.org on 2022/10/19 13:29:43 UTC
[doris] branch master updated: [bugfix](array-type) ColumnDate lost is_date_type after cloned (#13420)
This is an automated email from the ASF dual-hosted git repository.
xuyang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 9ac4cfc9bb [bugfix](array-type) ColumnDate lost is_date_type after cloned (#13420)
9ac4cfc9bb is described below
commit 9ac4cfc9bb57766ea08e97456605bad456976aa7
Author: camby <10...@qq.com>
AuthorDate: Wed Oct 19 21:29:36 2022 +0800
[bugfix](array-type) ColumnDate lost is_date_type after cloned (#13420)
Problem:
IColumn::is_date property will lost after ColumnDate::clone called.
Fix:
After ColumnDate created, also set IColumn::is_date.
Co-authored-by: cambyzju <zh...@baidu.com>
---
be/src/vec/columns/column.h | 9 +++++++++
be/src/vec/columns/column_vector.cpp | 16 ++++++++++++++--
.../array_functions/test_array_functions.out | 9 +++++++++
.../array_functions/test_array_functions.groovy | 19 +++++++++++--------
4 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/be/src/vec/columns/column.h b/be/src/vec/columns/column.h
index 46b93f6e2d..e0d99cd6d0 100644
--- a/be/src/vec/columns/column.h
+++ b/be/src/vec/columns/column.h
@@ -614,6 +614,15 @@ public:
virtual void set_datetime_type() { is_date_time = true; }
virtual void set_decimalv2_type() { is_decimalv2 = true; }
+ void copy_date_types(const IColumn& col) {
+ if (col.is_date_type()) {
+ set_date_type();
+ }
+ if (col.is_datetime_type()) {
+ set_datetime_type();
+ }
+ }
+
// todo(wb): a temporary implemention, need re-abstract here
bool is_date = false;
bool is_date_time = false;
diff --git a/be/src/vec/columns/column_vector.cpp b/be/src/vec/columns/column_vector.cpp
index 4bd84f8856..90925a09fc 100644
--- a/be/src/vec/columns/column_vector.cpp
+++ b/be/src/vec/columns/column_vector.cpp
@@ -313,6 +313,9 @@ const char* ColumnVector<T>::get_family_name() const {
template <typename T>
MutableColumnPtr ColumnVector<T>::clone_resized(size_t size) const {
auto res = this->create();
+ if constexpr (std::is_same_v<T, vectorized::Int64>) {
+ res->copy_date_types(*this);
+ }
if (size > 0) {
auto& new_col = assert_cast<Self&>(*res);
@@ -386,6 +389,9 @@ ColumnPtr ColumnVector<T>::filter(const IColumn::Filter& filt, ssize_t result_si
}
auto res = this->create();
+ if constexpr (std::is_same_v<T, vectorized::Int64>) {
+ res->copy_date_types(*this);
+ }
Container& res_data = res->get_data();
res_data.reserve(result_size_hint > 0 ? result_size_hint : size);
@@ -445,6 +451,9 @@ ColumnPtr ColumnVector<T>::permute(const IColumn::Permutation& perm, size_t limi
}
auto res = this->create(limit);
+ if constexpr (std::is_same_v<T, vectorized::Int64>) {
+ res->copy_date_types(*this);
+ }
typename Self::Container& res_data = res->get_data();
for (size_t i = 0; i < limit; ++i) res_data[i] = data[perm[i]];
@@ -458,9 +467,12 @@ ColumnPtr ColumnVector<T>::replicate(const IColumn::Offsets& offsets) const {
LOG(FATAL) << "Size of offsets doesn't match size of column.";
}
- if (0 == size) return this->create();
-
auto res = this->create();
+ if constexpr (std::is_same_v<T, vectorized::Int64>) {
+ res->copy_date_types(*this);
+ }
+ if (0 == size) return res;
+
typename Self::Container& res_data = res->get_data();
res_data.reserve(offsets.back());
diff --git a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
index 2a2f2c933b..8bcc53a962 100644
--- a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
+++ b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
@@ -134,3 +134,12 @@
6 \N
7 \N
+-- !select --
+1 \N
+2 \N
+3 \N
+4 \N
+5 \N
+6 \N
+7 \N
+
diff --git a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
index a4f6c60dd4..901a0c9650 100644
--- a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
+++ b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
@@ -29,7 +29,9 @@ suite("test_array_functions") {
`k2` ARRAY<int(11)> NOT NULL COMMENT "",
`k3` ARRAY<VARCHAR(20)> NULL COMMENT "",
`k4` ARRAY<int(11)> NULL COMMENT "",
- `k5` ARRAY<CHAR(5)> NULL COMMENT ""
+ `k5` ARRAY<CHAR(5)> NULL COMMENT "",
+ `k6` ARRAY<date> NULL COMMENT "",
+ `k7` ARRAY<datetime> NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`k1`)
DISTRIBUTED BY HASH(`k1`) BUCKETS 1
@@ -38,13 +40,13 @@ suite("test_array_functions") {
"storage_format" = "V2"
)
"""
- sql """ INSERT INTO ${tableName} VALUES(1,[1,2,3],["a","b",""],[1,2],["hi"]) """
- sql """ INSERT INTO ${tableName} VALUES(2,[4],NULL,[5],["hi2"]) """
- sql """ INSERT INTO ${tableName} VALUES(3,[],[],NULL,["hi3"]) """
- sql """ INSERT INTO ${tableName} VALUES(4,[1,2,3,4,5,4,3,2,1],[],[],NULL) """
- sql """ INSERT INTO ${tableName} VALUES(5,[],["a","b","c","d","c","b","a"],NULL,NULL) """
- sql """ INSERT INTO ${tableName} VALUES(6,[1,2,3,4,5,4,3,2,1],["a","b","c","d","c","b","a"],NULL,NULL) """
- sql """ INSERT INTO ${tableName} VALUES(7,[8,9,NULL,10,NULL],["f",NULL,"g",NULL,"h"],NULL,NULL) """
+ sql """ INSERT INTO ${tableName} VALUES(1,[1,2,3],["a","b",""],[1,2],["hi"],["2015-03-13"],["2015-03-13 12:36:38"]) """
+ sql """ INSERT INTO ${tableName} VALUES(2,[4],NULL,[5],["hi2"],NULL,NULL) """
+ sql """ INSERT INTO ${tableName} VALUES(3,[],[],NULL,["hi3"],NULL,NULL) """
+ sql """ INSERT INTO ${tableName} VALUES(4,[1,2,3,4,5,4,3,2,1],[],[],NULL,NULL,NULL) """
+ sql """ INSERT INTO ${tableName} VALUES(5,[],["a","b","c","d","c","b","a"],NULL,NULL,NULL,NULL) """
+ sql """ INSERT INTO ${tableName} VALUES(6,[1,2,3,4,5,4,3,2,1],["a","b","c","d","c","b","a"],NULL,NULL,NULL,NULL) """
+ sql """ INSERT INTO ${tableName} VALUES(7,[8,9,NULL,10,NULL],["f",NULL,"g",NULL,"h"],NULL,NULL,NULL,NULL) """
qt_select "SELECT k1, size(k2), size(k3) FROM ${tableName} ORDER BY k1"
qt_select "SELECT k1, cardinality(k2), cardinality(k3) FROM ${tableName} ORDER BY k1"
@@ -61,4 +63,5 @@ suite("test_array_functions") {
qt_select "SELECT k1, array_join(k2, '_', 'null'), array_join(k3, '-', 'null') FROM ${tableName} ORDER BY k1"
qt_select "SELECT k1, array_contains(k5, 'hi') FROM ${tableName} ORDER BY k1"
qt_select "SELECT k1, array_contains(k5, 'hi222') FROM ${tableName} ORDER BY k1"
+ qt_select "SELECT k1, array_contains(k6, null) from ${tableName} ORDER BY k1"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org