This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 7261845b3d [FIX](complex-type)fix complex type nested col_const
(#22375)
7261845b3d is described below
commit 7261845b3d0f5335f5ff8a43a6ef16a9282e073d
Author: amory <[email protected]>
AuthorDate: Mon Jul 31 14:53:18 2023 +0800
[FIX](complex-type)fix complex type nested col_const (#22375)
for array/map/struct in mysql_writer unpack_if_const only unpack self
column not nested , so col_const should not used in nested column.
---
.../vec/data_types/serde/data_type_array_serde.cpp | 4 ++--
.../vec/data_types/serde/data_type_map_serde.cpp | 12 +++++-----
.../data_types/serde/data_type_nullable_serde.cpp | 1 +
.../data_types/serde/data_type_struct_serde.cpp | 4 ++--
.../stream_load/test_map_load_and_function.out | 3 +++
.../test_array_functions_by_literal.out | 3 +++
.../array_functions/test_array_with_scale_type.out | 28 +++++++++++-----------
.../test_struct_functions_by_literal.out | 3 +++
.../stream_load/test_map_load_and_function.groovy | 2 ++
.../test_array_functions_by_literal.groovy | 4 ++++
.../test_struct_functions_by_literal.groovy | 3 +++
11 files changed, 43 insertions(+), 24 deletions(-)
diff --git a/be/src/vec/data_types/serde/data_type_array_serde.cpp
b/be/src/vec/data_types/serde/data_type_array_serde.cpp
index 596209c9aa..93cc45414d 100644
--- a/be/src/vec/data_types/serde/data_type_array_serde.cpp
+++ b/be/src/vec/data_types/serde/data_type_array_serde.cpp
@@ -117,12 +117,12 @@ Status DataTypeArraySerDe::_write_column_to_mysql(const
IColumn& column,
if (0 != result.push_string("\"", 1)) {
return Status::InternalError("pack mysql buffer failed.");
}
- RETURN_IF_ERROR(nested_serde->write_column_to_mysql(data,
result, j, col_const));
+ RETURN_IF_ERROR(nested_serde->write_column_to_mysql(data,
result, j, false));
if (0 != result.push_string("\"", 1)) {
return Status::InternalError("pack mysql buffer failed.");
}
} else {
- RETURN_IF_ERROR(nested_serde->write_column_to_mysql(data,
result, j, col_const));
+ RETURN_IF_ERROR(nested_serde->write_column_to_mysql(data,
result, j, false));
}
}
}
diff --git a/be/src/vec/data_types/serde/data_type_map_serde.cpp
b/be/src/vec/data_types/serde/data_type_map_serde.cpp
index fcf67a8f53..5b7bb09147 100644
--- a/be/src/vec/data_types/serde/data_type_map_serde.cpp
+++ b/be/src/vec/data_types/serde/data_type_map_serde.cpp
@@ -146,13 +146,13 @@ Status DataTypeMapSerDe::_write_column_to_mysql(const
IColumn& column,
return Status::InternalError("pack mysql buffer failed.");
}
RETURN_IF_ERROR(
- key_serde->write_column_to_mysql(nested_keys_column,
result, j, col_const));
+ key_serde->write_column_to_mysql(nested_keys_column,
result, j, false));
if (0 != result.push_string("\"", 1)) {
return Status::InternalError("pack mysql buffer failed.");
}
} else {
RETURN_IF_ERROR(
- key_serde->write_column_to_mysql(nested_keys_column,
result, j, col_const));
+ key_serde->write_column_to_mysql(nested_keys_column,
result, j, false));
}
}
if (0 != result.push_string(":", 1)) {
@@ -167,14 +167,14 @@ Status DataTypeMapSerDe::_write_column_to_mysql(const
IColumn& column,
if (0 != result.push_string("\"", 1)) {
return Status::InternalError("pack mysql buffer failed.");
}
-
RETURN_IF_ERROR(value_serde->write_column_to_mysql(nested_values_column,
result, j,
- col_const));
+ RETURN_IF_ERROR(
+
value_serde->write_column_to_mysql(nested_values_column, result, j, false));
if (0 != result.push_string("\"", 1)) {
return Status::InternalError("pack mysql buffer failed.");
}
} else {
-
RETURN_IF_ERROR(value_serde->write_column_to_mysql(nested_values_column,
result, j,
- col_const));
+ RETURN_IF_ERROR(
+
value_serde->write_column_to_mysql(nested_values_column, result, j, false));
}
}
}
diff --git a/be/src/vec/data_types/serde/data_type_nullable_serde.cpp
b/be/src/vec/data_types/serde/data_type_nullable_serde.cpp
index b40acdfd0d..bc4187ea23 100644
--- a/be/src/vec/data_types/serde/data_type_nullable_serde.cpp
+++ b/be/src/vec/data_types/serde/data_type_nullable_serde.cpp
@@ -167,6 +167,7 @@ Status DataTypeNullableSerDe::_write_column_to_mysql(const
IColumn& column,
int row_idx, bool
col_const) const {
auto& col = static_cast<const ColumnNullable&>(column);
auto& nested_col = col.get_nested_column();
+ col_const = col_const || is_column_const(nested_col);
const auto col_index = index_check_const(row_idx, col_const);
if (col.has_null() && col.is_null_at(col_index)) {
if (UNLIKELY(0 != result.push_null())) {
diff --git a/be/src/vec/data_types/serde/data_type_struct_serde.cpp
b/be/src/vec/data_types/serde/data_type_struct_serde.cpp
index ed6e9c1b7b..4dd8086fb9 100644
--- a/be/src/vec/data_types/serde/data_type_struct_serde.cpp
+++ b/be/src/vec/data_types/serde/data_type_struct_serde.cpp
@@ -106,13 +106,13 @@ Status DataTypeStructSerDe::_write_column_to_mysql(const
IColumn& column,
return Status::InternalError("pack mysql buffer failed.");
}
RETURN_IF_ERROR(elemSerDeSPtrs[j]->write_column_to_mysql(col.get_column(j),
result,
-
col_index, col_const));
+
col_index, false));
if (0 != result.push_string("\"", 1)) {
return Status::InternalError("pack mysql buffer failed.");
}
} else {
RETURN_IF_ERROR(elemSerDeSPtrs[j]->write_column_to_mysql(col.get_column(j),
result,
-
col_index, col_const));
+
col_index, false));
}
}
begin = false;
diff --git
a/regression-test/data/load_p0/stream_load/test_map_load_and_function.out
b/regression-test/data/load_p0/stream_load/test_map_load_and_function.out
index c493af4441..71cd0b7528 100644
--- a/regression-test/data/load_p0/stream_load/test_map_load_and_function.out
+++ b/regression-test/data/load_p0/stream_load/test_map_load_and_function.out
@@ -63,6 +63,9 @@
-- !select_map3 --
{}
+-- !select_map4 --
+{1000:"k11", 2000:"k22"}
+
-- !select_element1 --
1000
diff --git
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
index 6d2e316090..63103fa437 100644
---
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
+++
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
@@ -1,4 +1,7 @@
-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql --
+[1, 1, 2, 2, 2, 2]
+
-- !sql --
true
diff --git
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out
index e2b4a2a2af..b887cdf11b 100644
---
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out
+++
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out
@@ -58,8 +58,8 @@
[23.679]
-- !select --
-[24.990, 24.990]
-[24.990, 24.990]
+[24.990, 25.990]
+[24.990, 25.990]
-- !select --
[24.990, 25.990]
@@ -69,8 +69,8 @@
[34.679]
-- !select --
-[24.990, 24.990]
-[24.990, 24.990]
+[24.990, 25.990]
+[24.990, 25.990]
-- !select --
[24.990, 25.990]
@@ -80,8 +80,8 @@
[2022-12-02 22:23:24.999]
-- !select --
-[2022-12-02 22:23:24.999, 2022-12-02 22:23:24.999]
-[2022-12-02 22:23:24.999, 2022-12-02 22:23:24.999]
+[2022-12-02 22:23:24.999, 2022-12-02 22:23:23.997]
+[2022-12-02 22:23:24.999, 2022-12-02 22:23:23.997]
-- !select --
[2022-12-02 22:23:24.999, 2022-12-02 22:23:23.997]
@@ -111,8 +111,8 @@
\N
-- !select --
-[2022-12-02 22:23:24.999, 2022-12-02 22:23:24.999]
-[2022-12-02 22:23:24.999, 2022-12-02 22:23:24.999]
+[2022-12-02 22:23:24.999, 2022-12-02 22:23:23.997]
+[2022-12-02 22:23:24.999, 2022-12-02 22:23:23.997]
-- !select --
[2022-12-01 22:23:24.999, 2022-12-01 23:23:24.999]
@@ -131,8 +131,8 @@
[{23.679, 23.679, 2022-12-02 22:23:24.999, 23.679}, {34.679, 34.679,
2022-12-02 23:23:24.999, 34.679}]
-- !select --
-[{2022-12-02 22:23:24.999}, {2022-12-02 22:23:24.999}]
-[{2022-12-02 22:23:24.999}, {2022-12-02 22:23:24.999}]
+[{2022-12-02 22:23:24.999}, {2022-12-02 22:23:23.997}]
+[{2022-12-02 22:23:24.999}, {2022-12-02 22:23:23.997}]
-- !select --
[{2022-12-01 22:23:24.999}, {2022-12-01 23:23:24.999}]
@@ -143,8 +143,8 @@
[{2022-12-02 22:23:24.999, 2022-12-02 22:23:24.999}, {2022-12-02 23:23:24.999,
2022-12-02 22:23:23.997}]
-- !select --
-[2022-12-02 22:23:23.997, 2022-12-02 22:23:23.997]
-[2022-12-02 22:23:23.997, 2022-12-02 22:23:23.997]
+[2022-12-02 22:23:23.997, 2022-12-02 22:23:24.999]
+[2022-12-02 22:23:23.997, 2022-12-02 22:23:24.999]
-- !select --
[2023-03-08 23:23:23.997, 2022-12-01 22:23:24.999, 2022-12-01 23:23:24.999]
@@ -163,8 +163,8 @@
23.679 [23.679, 34.679] [23.679, 23.679, 34.679]
-- !select --
-[2022-12-02 22:23:24.999, 2022-12-02 22:23:24.999]
-[2022-12-02 22:23:24.999, 2022-12-02 22:23:24.999]
+[2022-12-02 22:23:24.999, 2022-12-02 22:23:23.997]
+[2022-12-02 22:23:24.999, 2022-12-02 22:23:23.997]
-- !select --
[2022-12-01 22:23:24.999, 2022-12-01 23:23:24.999, 2023-03-08 23:23:23.997]
diff --git
a/regression-test/data/query_p0/sql_functions/struct_functions/test_struct_functions_by_literal.out
b/regression-test/data/query_p0/sql_functions/struct_functions/test_struct_functions_by_literal.out
index 17e391b283..d6e14a7cc4 100644
---
a/regression-test/data/query_p0/sql_functions/struct_functions/test_struct_functions_by_literal.out
+++
b/regression-test/data/query_p0/sql_functions/struct_functions/test_struct_functions_by_literal.out
@@ -1,4 +1,7 @@
-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql --
+{"a", 1, "doris", "aaaaa", 1.32}
+
-- !sql --
{1, 2, 3}
diff --git
a/regression-test/suites/load_p0/stream_load/test_map_load_and_function.groovy
b/regression-test/suites/load_p0/stream_load/test_map_load_and_function.groovy
index 5ef0208bb2..c3e6ab8a20 100644
---
a/regression-test/suites/load_p0/stream_load/test_map_load_and_function.groovy
+++
b/regression-test/suites/load_p0/stream_load/test_map_load_and_function.groovy
@@ -79,6 +79,8 @@ suite("test_map_load_and_function", "p0") {
qt_select_map1 "SELECT map('k11', 1000, 'k22', 2000)"
qt_select_map2 "SELECT map(1000, 'k11', 2000, 'k22')"
qt_select_map3 "SELECT map()"
+ // map nested
+ qt_select_map4 "select m from (SELECT map(1000, 'k11', 2000, 'k22') as m)
t"
// map element_at
qt_select_element1 "SELECT map('k11', 1000, 'k22', 2000)['k11']"
diff --git
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
index c29bf53103..d969312431 100644
---
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
+++
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
@@ -16,6 +16,10 @@
// under the License.
suite("test_array_functions_by_literal") {
+ // array_nested function
+ qt_sql "select a from (select array(1, 1, 2, 2, 2, 2) as a) t"
+
+
// array_contains function
qt_sql "select array_contains([1,2,3], 1)"
qt_sql "select array_contains([1,2,3], 4)"
diff --git
a/regression-test/suites/query_p0/sql_functions/struct_functions/test_struct_functions_by_literal.groovy
b/regression-test/suites/query_p0/sql_functions/struct_functions/test_struct_functions_by_literal.groovy
index a7ae109fd3..d394b3cbd4 100644
---
a/regression-test/suites/query_p0/sql_functions/struct_functions/test_struct_functions_by_literal.groovy
+++
b/regression-test/suites/query_p0/sql_functions/struct_functions/test_struct_functions_by_literal.groovy
@@ -16,6 +16,9 @@
// under the License.
suite("test_struct_functions_by_literal") {
+ // struct-nested
+ qt_sql "select s from (select struct('a', 1, 'doris', 'aaaaa', 1.32) as s)
t"
+
// struct constructor
qt_sql "select struct(1, 2, 3)"
qt_sql "select struct(1, 1000, 10000000000)"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]