You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/07/20 12:17:48 UTC
[doris] branch master updated: [Bug] fix bug for function `unix_timestamp` (#11041)
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 b115b362fb [Bug] fix bug for function `unix_timestamp` (#11041)
b115b362fb is described below
commit b115b362fb57744960c5efc8a59f5c724263f218
Author: Gabriel <ga...@gmail.com>
AuthorDate: Wed Jul 20 20:17:41 2022 +0800
[Bug] fix bug for function `unix_timestamp` (#11041)
* [Bug] fix bug for function `unix_timestamp`
---
be/src/vec/functions/function_timestamp.cpp | 8 +++++++-
.../query/sql_functions/datetime_functions/test_date_function.out | 3 +++
.../sql_functions/datetime_functions/test_date_function.groovy | 2 ++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/be/src/vec/functions/function_timestamp.cpp b/be/src/vec/functions/function_timestamp.cpp
index 691714cb33..8a50953e85 100644
--- a/be/src/vec/functions/function_timestamp.cpp
+++ b/be/src/vec/functions/function_timestamp.cpp
@@ -206,7 +206,13 @@ struct UnixTimeStampImpl {
const ColumnNumbers& arguments, size_t result,
size_t input_rows_count) {
auto col_result = ColumnVector<Int32>::create();
- col_result->insert(context->impl()->state()->timestamp_ms() / 1000);
+ col_result->resize(input_rows_count);
+ // TODO: use a const column to store this value
+ auto& col_result_data = col_result->get_data();
+ auto res_value = context->impl()->state()->timestamp_ms() / 1000;
+ for (int i = 0; i < input_rows_count; i++) {
+ col_result_data[i] = res_value;
+ }
block.replace_by_position(result, std::move(col_result));
return Status::OK();
}
diff --git a/regression-test/data/query/sql_functions/datetime_functions/test_date_function.out b/regression-test/data/query/sql_functions/datetime_functions/test_date_function.out
index 25b2d58cb3..c02183d1c3 100644
--- a/regression-test/data/query/sql_functions/datetime_functions/test_date_function.out
+++ b/regression-test/data/query/sql_functions/datetime_functions/test_date_function.out
@@ -287,3 +287,6 @@ February
-- !sql --
202026
+-- !sql --
+200
+
diff --git a/regression-test/suites/query/sql_functions/datetime_functions/test_date_function.groovy b/regression-test/suites/query/sql_functions/datetime_functions/test_date_function.groovy
index b963ab7870..eada2080eb 100644
--- a/regression-test/suites/query/sql_functions/datetime_functions/test_date_function.groovy
+++ b/regression-test/suites/query/sql_functions/datetime_functions/test_date_function.groovy
@@ -250,5 +250,7 @@ suite("test_date_function", "query") {
qt_sql """ select yearweek('2021-1-1') """
qt_sql """ select yearweek('2020-7-1') """
+ qt_sql """ select count(*) from (select * from numbers("200")) tmp1 WHERE 0 <= UNIX_TIMESTAMP(); """
+
sql """ drop table ${tableName} """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org