This is an automated email from the ASF dual-hosted git repository. yangbowen 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 31db952eb98 [optimize](information_schema) optimize the data type of table information_schema.rowsets (#34739) 31db952eb98 is described below commit 31db952eb982648b3374c3d4d3ca2fac822aebe3 Author: Xujian Duan <50550370+darvend...@users.noreply.github.com> AuthorDate: Tue May 21 13:28:49 2024 +0800 [optimize](information_schema) optimize the data type of table information_schema.rowsets (#34739) * optimize the data type of table imformation_schema.rowsets --------- Co-authored-by: duanxujian <duanxuj...@jd.com> --- be/src/exec/schema_scanner/schema_rowsets_scanner.cpp | 16 ++++++++++------ .../main/java/org/apache/doris/catalog/SchemaTable.java | 4 ++-- .../data/query_p0/system/test_query_sys_rowsets.out | 14 +++++++++++--- .../suites/query_p0/system/test_query_sys_rowsets.groovy | 9 ++++++++- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/be/src/exec/schema_scanner/schema_rowsets_scanner.cpp b/be/src/exec/schema_scanner/schema_rowsets_scanner.cpp index b03a30b2d92..f66363fde1e 100644 --- a/be/src/exec/schema_scanner/schema_rowsets_scanner.cpp +++ b/be/src/exec/schema_scanner/schema_rowsets_scanner.cpp @@ -56,8 +56,8 @@ std::vector<SchemaScanner::ColumnDesc> SchemaRowsetsScanner::_s_tbls_columns = { {"END_VERSION", TYPE_BIGINT, sizeof(int64_t), true}, {"INDEX_DISK_SIZE", TYPE_BIGINT, sizeof(size_t), true}, {"DATA_DISK_SIZE", TYPE_BIGINT, sizeof(size_t), true}, - {"CREATION_TIME", TYPE_BIGINT, sizeof(int64_t), true}, - {"NEWEST_WRITE_TIMESTAMP", TYPE_BIGINT, sizeof(int64_t), true}, + {"CREATION_TIME", TYPE_DATETIME, sizeof(int64_t), true}, + {"NEWEST_WRITE_TIMESTAMP", TYPE_DATETIME, sizeof(int64_t), true}, }; @@ -221,24 +221,28 @@ Status SchemaRowsetsScanner::_fill_block_impl(vectorized::Block* block) { } // CREATION_TIME { - std::vector<int64_t> srcs(fill_rowsets_num); + std::vector<VecDateTimeValue> srcs(fill_rowsets_num); for (int i = fill_idx_begin; i < fill_idx_end; ++i) { RowsetSharedPtr rowset = rowsets_[i]; - srcs[i - fill_idx_begin] = rowset->creation_time(); + int64_t creation_time = rowset->creation_time(); + srcs[i - fill_idx_begin].from_unixtime(creation_time, TimezoneUtils::default_time_zone); datas[i - fill_idx_begin] = srcs.data() + i - fill_idx_begin; } RETURN_IF_ERROR(fill_dest_column_for_range(block, 10, datas)); } // NEWEST_WRITE_TIMESTAMP { - std::vector<int64_t> srcs(fill_rowsets_num); + std::vector<VecDateTimeValue> srcs(fill_rowsets_num); for (int i = fill_idx_begin; i < fill_idx_end; ++i) { RowsetSharedPtr rowset = rowsets_[i]; - srcs[i - fill_idx_begin] = rowset->newest_write_timestamp(); + int64_t newest_write_timestamp = rowset->newest_write_timestamp(); + srcs[i - fill_idx_begin].from_unixtime(newest_write_timestamp, + TimezoneUtils::default_time_zone); datas[i - fill_idx_begin] = srcs.data() + i - fill_idx_begin; } RETURN_IF_ERROR(fill_dest_column_for_range(block, 11, datas)); } + _rowsets_idx += fill_rowsets_num; return Status::OK(); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java index 92206dc3fdb..88349942719 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java @@ -395,8 +395,8 @@ public class SchemaTable extends Table { .column("END_VERSION", ScalarType.createType(PrimitiveType.BIGINT)) .column("INDEX_DISK_SIZE", ScalarType.createType(PrimitiveType.BIGINT)) .column("DATA_DISK_SIZE", ScalarType.createType(PrimitiveType.BIGINT)) - .column("CREATION_TIME", ScalarType.createType(PrimitiveType.BIGINT)) - .column("NEWEST_WRITE_TIMESTAMP", ScalarType.createType(PrimitiveType.BIGINT)) + .column("CREATION_TIME", ScalarType.createType(PrimitiveType.DATETIME)) + .column("NEWEST_WRITE_TIMESTAMP", ScalarType.createType(PrimitiveType.DATETIME)) .build())) .put("parameters", new SchemaTable(SystemIdGenerator.getNextId(), "parameters", TableType.SCHEMA, builder().column("SPECIFIC_CATALOG", ScalarType.createVarchar(64)) diff --git a/regression-test/data/query_p0/system/test_query_sys_rowsets.out b/regression-test/data/query_p0/system/test_query_sys_rowsets.out index 958d57d68e4..8c9bb68893d 100644 --- a/regression-test/data/query_p0/system/test_query_sys_rowsets.out +++ b/regression-test/data/query_p0/system/test_query_sys_rowsets.out @@ -10,8 +10,8 @@ START_VERSION BIGINT Yes false \N END_VERSION BIGINT Yes false \N INDEX_DISK_SIZE BIGINT Yes false \N DATA_DISK_SIZE BIGINT Yes false \N -CREATION_TIME BIGINT Yes false \N -NEWEST_WRITE_TIMESTAMP BIGINT Yes false \N +CREATION_TIME DATETIME Yes false \N +NEWEST_WRITE_TIMESTAMP DATETIME Yes false \N -- !rowsets1 -- 0 1 @@ -24,4 +24,12 @@ NEWEST_WRITE_TIMESTAMP BIGINT Yes false \N 0 1 2 2 3 3 -4 4 \ No newline at end of file +4 4 + +-- !rowsets4 -- +0 1 +2 2 +3 3 +4 4 +5 5 + diff --git a/regression-test/suites/query_p0/system/test_query_sys_rowsets.groovy b/regression-test/suites/query_p0/system/test_query_sys_rowsets.groovy index 1f159e38329..cd4906e60f4 100644 --- a/regression-test/suites/query_p0/system/test_query_sys_rowsets.groovy +++ b/regression-test/suites/query_p0/system/test_query_sys_rowsets.groovy @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +import java.text.SimpleDateFormat; +import java.util.Date; + suite("test_query_sys_rowsets", "query,p0") { def dbName1 = "test_query_sys_rowsets" @@ -38,6 +41,9 @@ suite("test_query_sys_rowsets", "query,p0") { ); """ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") + def now = sdf.format(new Date()).toString(); + List<List<Object>> rowsets_table_name_tablets = sql """ show tablets from ${rowsets_table_name} """ order_qt_rowsets1 """ select START_VERSION,END_VERSION from information_schema.rowsets where TABLET_ID=${rowsets_table_name_tablets[0][0]} order by START_VERSION,END_VERSION; """ sql """ insert into ${rowsets_table_name} values (1,0,"abc"); """ @@ -45,5 +51,6 @@ suite("test_query_sys_rowsets", "query,p0") { sql """ insert into ${rowsets_table_name} values (2,1,"hello world"); """ sql """ insert into ${rowsets_table_name} values (3,0,"dssadasdsafafdf"); """ order_qt_rowsets3 """ select START_VERSION,END_VERSION from information_schema.rowsets where TABLET_ID=${rowsets_table_name_tablets[0][0]} order by START_VERSION,END_VERSION; """ - + sql """ insert into ${rowsets_table_name} values (4,0,"abcd"); """ + order_qt_rowsets4 """ select START_VERSION,END_VERSION from information_schema.rowsets where TABLET_ID=${rowsets_table_name_tablets[0][0]} and NEWEST_WRITE_TIMESTAMP>='${now}' order by START_VERSION,END_VERSION; """ } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org