[Bug] fix bug for function unix_timestamp (#11041)

* [Bug] fix bug for function `unix_timestamp`
This commit is contained in:
Gabriel
2022-07-20 20:17:41 +08:00
committed by GitHub
parent b95dedd07b
commit b115b362fb
3 changed files with 12 additions and 1 deletions

View File

@ -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();
}

View File

@ -287,3 +287,6 @@ February
-- !sql --
202026
-- !sql --
200

View File

@ -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} """
}