diff --git a/src/catalog/src/system_schema/information_schema/tables.rs b/src/catalog/src/system_schema/information_schema/tables.rs index 8c288b8e57..f96d47b16d 100644 --- a/src/catalog/src/system_schema/information_schema/tables.rs +++ b/src/catalog/src/system_schema/information_schema/tables.rs @@ -30,8 +30,7 @@ use datatypes::prelude::{ConcreteDataType, ScalarVectorBuilder, VectorRef}; use datatypes::schema::{ColumnSchema, Schema, SchemaRef}; use datatypes::value::Value; use datatypes::vectors::{ - StringVectorBuilder, TimestampMicrosecondVectorBuilder, UInt32VectorBuilder, - UInt64VectorBuilder, + StringVectorBuilder, TimestampSecondVectorBuilder, UInt32VectorBuilder, UInt64VectorBuilder, }; use futures::TryStreamExt; use snafu::{OptionExt, ResultExt}; @@ -107,17 +106,17 @@ impl InformationSchemaTables { ColumnSchema::new(AUTO_INCREMENT, ConcreteDataType::uint64_datatype(), true), ColumnSchema::new( CREATE_TIME, - ConcreteDataType::timestamp_microsecond_datatype(), + ConcreteDataType::timestamp_second_datatype(), true, ), ColumnSchema::new( UPDATE_TIME, - ConcreteDataType::timestamp_microsecond_datatype(), + ConcreteDataType::timestamp_second_datatype(), true, ), ColumnSchema::new( CHECK_TIME, - ConcreteDataType::timestamp_microsecond_datatype(), + ConcreteDataType::timestamp_second_datatype(), true, ), ColumnSchema::new(TABLE_COLLATION, ConcreteDataType::string_datatype(), true), @@ -194,9 +193,9 @@ struct InformationSchemaTablesBuilder { max_index_length: UInt64VectorBuilder, data_free: UInt64VectorBuilder, auto_increment: UInt64VectorBuilder, - create_time: TimestampMicrosecondVectorBuilder, - update_time: TimestampMicrosecondVectorBuilder, - check_time: TimestampMicrosecondVectorBuilder, + create_time: TimestampSecondVectorBuilder, + update_time: TimestampSecondVectorBuilder, + check_time: TimestampSecondVectorBuilder, table_collation: StringVectorBuilder, checksum: UInt64VectorBuilder, create_options: StringVectorBuilder, @@ -231,9 +230,9 @@ impl InformationSchemaTablesBuilder { max_index_length: UInt64VectorBuilder::with_capacity(INIT_CAPACITY), data_free: UInt64VectorBuilder::with_capacity(INIT_CAPACITY), auto_increment: UInt64VectorBuilder::with_capacity(INIT_CAPACITY), - create_time: TimestampMicrosecondVectorBuilder::with_capacity(INIT_CAPACITY), - update_time: TimestampMicrosecondVectorBuilder::with_capacity(INIT_CAPACITY), - check_time: TimestampMicrosecondVectorBuilder::with_capacity(INIT_CAPACITY), + create_time: TimestampSecondVectorBuilder::with_capacity(INIT_CAPACITY), + update_time: TimestampSecondVectorBuilder::with_capacity(INIT_CAPACITY), + check_time: TimestampSecondVectorBuilder::with_capacity(INIT_CAPACITY), table_collation: StringVectorBuilder::with_capacity(INIT_CAPACITY), checksum: UInt64VectorBuilder::with_capacity(INIT_CAPACITY), create_options: StringVectorBuilder::with_capacity(INIT_CAPACITY), @@ -380,7 +379,7 @@ impl InformationSchemaTablesBuilder { self.create_options .push(Some(table_info.meta.options.to_string().as_ref())); self.create_time - .push(Some(table_info.meta.created_on.timestamp_millis().into())); + .push(Some(table_info.meta.created_on.timestamp().into())); self.temporary .push(if matches!(table_type, TableType::Temporary) { diff --git a/tests-integration/src/tests/instance_test.rs b/tests-integration/src/tests/instance_test.rs index 189ff379fe..8262d56b5c 100644 --- a/tests-integration/src/tests/instance_test.rs +++ b/tests-integration/src/tests/instance_test.rs @@ -1975,10 +1975,10 @@ async fn test_information_schema_dot_columns(instance: Arc) { | greptime | public | numbers | number | int unsigned | TAG | | greptime | information_schema | tables | auto_increment | bigint unsigned | FIELD | | greptime | information_schema | tables | avg_row_length | bigint unsigned | FIELD | -| greptime | information_schema | tables | check_time | timestamp(6) | FIELD | +| greptime | information_schema | tables | check_time | timestamp(0) | FIELD | | greptime | information_schema | tables | checksum | bigint unsigned | FIELD | | greptime | information_schema | tables | create_options | string | FIELD | -| greptime | information_schema | tables | create_time | timestamp(6) | FIELD | +| greptime | information_schema | tables | create_time | timestamp(0) | FIELD | | greptime | information_schema | tables | data_free | bigint unsigned | FIELD | | greptime | information_schema | tables | data_length | bigint unsigned | FIELD | | greptime | information_schema | tables | engine | string | FIELD | @@ -1995,7 +1995,7 @@ async fn test_information_schema_dot_columns(instance: Arc) { | greptime | information_schema | tables | table_schema | string | FIELD | | greptime | information_schema | tables | table_type | string | FIELD | | greptime | information_schema | tables | temporary | string | FIELD | -| greptime | information_schema | tables | update_time | timestamp(6) | FIELD | +| greptime | information_schema | tables | update_time | timestamp(0) | FIELD | | greptime | information_schema | tables | version | bigint unsigned | FIELD | +---------------+--------------------+------------+--------------------------+-----------------+---------------+"; @@ -2033,10 +2033,10 @@ async fn test_information_schema_dot_columns(instance: Arc) { | another_catalog | information_schema | columns | table_schema | string | FIELD | | another_catalog | information_schema | tables | auto_increment | bigint unsigned | FIELD | | another_catalog | information_schema | tables | avg_row_length | bigint unsigned | FIELD | -| another_catalog | information_schema | tables | check_time | timestamp(6) | FIELD | +| another_catalog | information_schema | tables | check_time | timestamp(0) | FIELD | | another_catalog | information_schema | tables | checksum | bigint unsigned | FIELD | | another_catalog | information_schema | tables | create_options | string | FIELD | -| another_catalog | information_schema | tables | create_time | timestamp(6) | FIELD | +| another_catalog | information_schema | tables | create_time | timestamp(0) | FIELD | | another_catalog | information_schema | tables | data_free | bigint unsigned | FIELD | | another_catalog | information_schema | tables | data_length | bigint unsigned | FIELD | | another_catalog | information_schema | tables | engine | string | FIELD | @@ -2053,7 +2053,7 @@ async fn test_information_schema_dot_columns(instance: Arc) { | another_catalog | information_schema | tables | table_schema | string | FIELD | | another_catalog | information_schema | tables | table_type | string | FIELD | | another_catalog | information_schema | tables | temporary | string | FIELD | -| another_catalog | information_schema | tables | update_time | timestamp(6) | FIELD | +| another_catalog | information_schema | tables | update_time | timestamp(0) | FIELD | | another_catalog | information_schema | tables | version | bigint unsigned | FIELD | +-----------------+--------------------+---------------+--------------------------+-----------------+---------------+"; diff --git a/tests/cases/standalone/common/system/information_schema.result b/tests/cases/standalone/common/system/information_schema.result index 645b5b7c3c..b207f6543c 100644 --- a/tests/cases/standalone/common/system/information_schema.result +++ b/tests/cases/standalone/common/system/information_schema.result @@ -394,10 +394,10 @@ select * from information_schema.columns order by table_schema, table_name, colu | greptime | information_schema | table_privileges | table_schema | 3 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | tables | auto_increment | 16 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | tables | avg_row_length | 10 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | -| greptime | information_schema | tables | check_time | 19 | | | | | 6 | | | | | select,insert | | TimestampMicrosecond | timestamp(6) | FIELD | | Yes | timestamp(6) | | | +| greptime | information_schema | tables | check_time | 19 | | | | | 0 | | | | | select,insert | | TimestampSecond | timestamp(0) | FIELD | | Yes | timestamp(0) | | | | greptime | information_schema | tables | checksum | 21 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | tables | create_options | 22 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | -| greptime | information_schema | tables | create_time | 17 | | | | | 6 | | | | | select,insert | | TimestampMicrosecond | timestamp(6) | FIELD | | Yes | timestamp(6) | | | +| greptime | information_schema | tables | create_time | 17 | | | | | 0 | | | | | select,insert | | TimestampSecond | timestamp(0) | FIELD | | Yes | timestamp(0) | | | | greptime | information_schema | tables | data_free | 15 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | tables | data_length | 6 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | tables | engine | 11 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | @@ -414,7 +414,7 @@ select * from information_schema.columns order by table_schema, table_name, colu | greptime | information_schema | tables | table_schema | 2 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | tables | table_type | 4 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | tables | temporary | 24 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | -| greptime | information_schema | tables | update_time | 18 | | | | | 6 | | | | | select,insert | | TimestampMicrosecond | timestamp(6) | FIELD | | Yes | timestamp(6) | | | +| greptime | information_schema | tables | update_time | 18 | | | | | 0 | | | | | select,insert | | TimestampSecond | timestamp(0) | FIELD | | Yes | timestamp(0) | | | | greptime | information_schema | tables | version | 12 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | triggers | flownode_id | 4 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | | greptime | information_schema | triggers | trigger_definition | 3 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | @@ -488,6 +488,17 @@ order by table_name; | foo | +------------+ +SELECT table_name +FROM information_schema.tables +WHERE table_schema = 'my_db' + AND create_time > NOW() - INTERVAL 1 MINUTE; + ++------------+ +| table_name | ++------------+ +| foo | ++------------+ + select table_name from information_schema.tables where table_schema in ('my_db', 'public') diff --git a/tests/cases/standalone/common/system/information_schema.sql b/tests/cases/standalone/common/system/information_schema.sql index f5767e4cb0..68bf931cff 100644 --- a/tests/cases/standalone/common/system/information_schema.sql +++ b/tests/cases/standalone/common/system/information_schema.sql @@ -32,6 +32,11 @@ from information_schema.tables where table_schema = 'my_db' order by table_name; +SELECT table_name +FROM information_schema.tables +WHERE table_schema = 'my_db' + AND create_time > NOW() - INTERVAL 1 MINUTE; + select table_name from information_schema.tables where table_schema in ('my_db', 'public')