diff --git a/src/mito2/src/read/scan_region.rs b/src/mito2/src/read/scan_region.rs index 0fe4c7efa2..53567236b2 100644 --- a/src/mito2/src/read/scan_region.rs +++ b/src/mito2/src/read/scan_region.rs @@ -817,8 +817,12 @@ impl StreamContext { } } - /// Format parts for explain. - pub(crate) fn format_parts(&self, t: DisplayFormatType, f: &mut fmt::Formatter) -> fmt::Result { + /// Format the context for explain. + pub(crate) fn format_for_explain( + &self, + t: DisplayFormatType, + f: &mut fmt::Formatter, + ) -> fmt::Result { match self.parts.try_lock() { Ok(inner) => match t { DisplayFormatType::Default => write!( @@ -827,10 +831,14 @@ impl StreamContext { inner.len(), inner.num_mem_ranges(), inner.num_file_ranges() - ), - DisplayFormatType::Verbose => write!(f, "{:?}", &*inner), + )?, + DisplayFormatType::Verbose => write!(f, "{:?}", &*inner)?, }, - Err(_) => write!(f, ""), + Err(_) => write!(f, "")?, } + if let Some(selector) = &self.input.series_row_selector { + write!(f, ", selector={}", selector)?; + } + Ok(()) } } diff --git a/src/mito2/src/read/seq_scan.rs b/src/mito2/src/read/seq_scan.rs index ca5de75058..0eb3f89d33 100644 --- a/src/mito2/src/read/seq_scan.rs +++ b/src/mito2/src/read/seq_scan.rs @@ -448,7 +448,7 @@ impl RegionScanner for SeqScan { impl DisplayAs for SeqScan { fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SeqScan: ")?; - self.stream_ctx.format_parts(t, f) + self.stream_ctx.format_for_explain(t, f) } } diff --git a/src/mito2/src/read/unordered_scan.rs b/src/mito2/src/read/unordered_scan.rs index 663097012b..2e4fd023e9 100644 --- a/src/mito2/src/read/unordered_scan.rs +++ b/src/mito2/src/read/unordered_scan.rs @@ -214,7 +214,7 @@ impl RegionScanner for UnorderedScan { impl DisplayAs for UnorderedScan { fn fmt_as(&self, t: DisplayFormatType, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "UnorderedScan: ")?; - self.stream_ctx.format_parts(t, f) + self.stream_ctx.format_for_explain(t, f) } } diff --git a/src/query/src/optimizer/scan_hint.rs b/src/query/src/optimizer/scan_hint.rs index 506b5c3c0e..e469e7f75b 100644 --- a/src/query/src/optimizer/scan_hint.rs +++ b/src/query/src/optimizer/scan_hint.rs @@ -212,8 +212,9 @@ impl TreeNodeVisitor<'_> for ScanHintVisitor { break; } } else if let Expr::Sort(sort_expr) = first_order_by { - // only allow `order by xxx [DESC]`, xxx is a bare column reference - if sort_expr.asc || !matches!(&*sort_expr.expr, Expr::Column(_)) { + // only allow `order by xxx [ASC]`, xxx is a bare column reference so `last_value()` is the max + // value of the column. + if !sort_expr.asc || !matches!(&*sort_expr.expr, Expr::Column(_)) { is_all_last_value = false; break; } @@ -335,7 +336,7 @@ mod test { filter: None, order_by: Some(vec![Expr::Sort(Sort { expr: Box::new(col("ts")), - asc: false, + asc: true, nulls_first: true, })]), null_treatment: None, diff --git a/src/store-api/src/storage/requests.rs b/src/store-api/src/storage/requests.rs index 42af126ff9..e1bf242468 100644 --- a/src/store-api/src/storage/requests.rs +++ b/src/store-api/src/storage/requests.rs @@ -14,9 +14,10 @@ use common_recordbatch::OrderOption; use datafusion_expr::expr::Expr; +use strum::Display; /// A hint on how to select rows from a time-series. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, Display)] pub enum TimeSeriesRowSelector { /// Only keep the last row of each time-series. LastRow, diff --git a/tests/cases/standalone/common/select/last_value.result b/tests/cases/standalone/common/select/last_value.result deleted file mode 100644 index c73205e989..0000000000 --- a/tests/cases/standalone/common/select/last_value.result +++ /dev/null @@ -1,34 +0,0 @@ -create table t ( - ts timestamp time index, - host string primary key, - not_pk string, - val double, -); - -Affected Rows: 0 - -insert into t values - (0, 'a', '🌕', 1.0), - (1, 'b', '🌖', 2.0), - (2, 'a', '🌗', 3.0), - (3, 'c', '🌘', 4.0), - (4, 'a', '🌑', 5.0), - (5, 'b', '🌒', 6.0), - (6, 'a', '🌓', 7.0), - (7, 'c', '🌔', 8.0), - (8, 'd', '🌕', 9.0); - -Affected Rows: 9 - --- Wait for #4354 --- explain analyze --- select --- last_value(host order by ts), --- last_value(not_pk order by ts), --- last_value(val order by ts) --- from t --- group by host; -drop table t; - -Affected Rows: 0 - diff --git a/tests/cases/standalone/common/show/show_databases_tables.result b/tests/cases/standalone/common/show/show_databases_tables.result index 21abd9d2ed..918a85a183 100644 --- a/tests/cases/standalone/common/show/show_databases_tables.result +++ b/tests/cases/standalone/common/show/show_databases_tables.result @@ -104,70 +104,74 @@ SHOW FULL TABLES; | views | LOCAL TEMPORARY | +---------------------------------------+-----------------+ --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ SHOW TABLE STATUS; -+---------------------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ -| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | -+---------------------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ -| build_info | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| character_sets | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| check_constraints | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| cluster_info | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| collation_character_set_applicability | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| collations | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| column_privileges | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| column_statistics | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| columns | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| engines | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| events | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| files | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| global_status | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| key_column_usage | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| optimizer_trace | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| parameters | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| partitions | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| profiling | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| referential_constraints | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| region_peers | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| routines | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| runtime_metrics | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| schema_privileges | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| schemata | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| session_status | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| table_constraints | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| table_privileges | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| tables | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| triggers | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -| views | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -+---------------------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ ++++++++++++++++++++ +|Name|Engine|Version|Row_format|Rows|Avg_row_length|Data_length|Max_data_length|Index_length|Data_free|Auto_increment|Create_time|Update_time|Check_time|Collation|Checksum|Create_options|Comment| ++++++++++++++++++++ +|build_info||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|character_sets||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|check_constraints||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|cluster_info||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|collation_character_set_applicability||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|collations||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|column_privileges||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|column_statistics||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|columns||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|engines||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|events||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|files||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|global_status||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|key_column_usage||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|optimizer_trace||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|parameters||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|partitions||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|profiling||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|referential_constraints||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|region_peers||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|routines||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|runtime_metrics||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|schema_privileges||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|schemata||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|session_status||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|table_constraints||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|table_privileges||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|tables||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|triggers||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| +|views||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| ++++++++++++++++++++ --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ SHOW TABLE STATUS LIKE 'tables'; -+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ -| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | -+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ -| tables | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ ++++++++++++++++++++ +|Name|Engine|Version|Row_format|Rows|Avg_row_length|Data_length|Max_data_length|Index_length|Data_free|Auto_increment|Create_time|Update_time|Check_time|Collation|Checksum|Create_options|Comment| ++++++++++++++++++++ +|tables||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| ++++++++++++++++++++ --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ SHOW TABLE STATUS WHERE Name = 'tables'; -+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ -| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | -+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ -| tables | | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -+--------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ ++++++++++++++++++++ +|Name|Engine|Version|Row_format|Rows|Avg_row_length|Data_length|Max_data_length|Index_length|Data_free|Auto_increment|Create_time|Update_time|Check_time|Collation|Checksum|Create_options|Comment| ++++++++++++++++++++ +|tables||11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| ++++++++++++++++++++ --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ SHOW TABLE STATUS from public; -+---------+-------------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ -| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | -+---------+-------------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ -| numbers | test_engine | 11 | Fixed | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DATETIME | | | | 0 | | | -+---------+-------------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------------------+-------------+------------+-----------+----------+----------------+---------+ ++++++++++++++++++++ +|Name|Engine|Version|Row_format|Rows|Avg_row_length|Data_length|Max_data_length|Index_length|Data_free|Auto_increment|Create_time|Update_time|Check_time|Collation|Checksum|Create_options|Comment| ++++++++++++++++++++ +|numbers|test_engine|11|Fixed|0|0|0|0|0|0|0|DATETIME||||0||| ++++++++++++++++++++ USE public; diff --git a/tests/cases/standalone/common/show/show_databases_tables.sql b/tests/cases/standalone/common/show/show_databases_tables.sql index 304aaae42c..0ef3fe4b41 100644 --- a/tests/cases/standalone/common/show/show_databases_tables.sql +++ b/tests/cases/standalone/common/show/show_databases_tables.sql @@ -10,16 +10,20 @@ SHOW TABLES LIKE 'tables'; SHOW FULL TABLES; --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ SHOW TABLE STATUS; --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ SHOW TABLE STATUS LIKE 'tables'; --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ SHOW TABLE STATUS WHERE Name = 'tables'; --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ SHOW TABLE STATUS from public; USE public; diff --git a/tests/cases/standalone/common/system/information_schema.result b/tests/cases/standalone/common/system/information_schema.result index 6de7002256..2202b25d9e 100644 --- a/tests/cases/standalone/common/system/information_schema.result +++ b/tests/cases/standalone/common/system/information_schema.result @@ -4,47 +4,48 @@ create database information_schema; Error: 1004(InvalidArguments), Schema information_schema already exists -- scripts table has different table ids in different modes --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ select * from information_schema.tables where table_name != 'scripts' order by table_schema, table_name; -+---------------+--------------------+---------------------------------------+-----------------+----------+-------------+-----------------+--------------+------------------+----------------+-------------+---------+------------+------------+-----------+----------------+-------------------------+-------------+------------+-----------------+----------+----------------+---------------+-----------+ -| table_catalog | table_schema | table_name | table_type | table_id | data_length | max_data_length | index_length | max_index_length | avg_row_length | engine | version | row_format | table_rows | data_free | auto_increment | create_time | update_time | check_time | table_collation | checksum | create_options | table_comment | temporary | -+---------------+--------------------+---------------------------------------+-----------------+----------+-------------+-----------------+--------------+------------------+----------------+-------------+---------+------------+------------+-----------+----------------+-------------------------+-------------+------------+-----------------+----------+----------------+---------------+-----------+ -| greptime | information_schema | build_info | LOCAL TEMPORARY | 8 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | character_sets | LOCAL TEMPORARY | 9 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | check_constraints | LOCAL TEMPORARY | 12 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | cluster_info | LOCAL TEMPORARY | 31 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | collation_character_set_applicability | LOCAL TEMPORARY | 11 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | collations | LOCAL TEMPORARY | 10 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | column_privileges | LOCAL TEMPORARY | 6 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | column_statistics | LOCAL TEMPORARY | 7 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | columns | LOCAL TEMPORARY | 4 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | engines | LOCAL TEMPORARY | 5 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | events | LOCAL TEMPORARY | 13 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | files | LOCAL TEMPORARY | 14 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | global_status | LOCAL TEMPORARY | 25 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | key_column_usage | LOCAL TEMPORARY | 16 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | optimizer_trace | LOCAL TEMPORARY | 17 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | parameters | LOCAL TEMPORARY | 18 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | partitions | LOCAL TEMPORARY | 28 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | profiling | LOCAL TEMPORARY | 19 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | referential_constraints | LOCAL TEMPORARY | 20 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | region_peers | LOCAL TEMPORARY | 29 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | routines | LOCAL TEMPORARY | 21 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | runtime_metrics | LOCAL TEMPORARY | 27 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | schema_privileges | LOCAL TEMPORARY | 22 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | schemata | LOCAL TEMPORARY | 15 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | session_status | LOCAL TEMPORARY | 26 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | table_constraints | LOCAL TEMPORARY | 30 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | table_privileges | LOCAL TEMPORARY | 23 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | tables | LOCAL TEMPORARY | 3 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | triggers | LOCAL TEMPORARY | 24 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | information_schema | views | LOCAL TEMPORARY | 32 | 0 | 0 | 0 | 0 | 0 | | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -| greptime | public | numbers | LOCAL TEMPORARY | 2 | 0 | 0 | 0 | 0 | 0 | test_engine | 11 | Fixed | 0 | 0 | 0 | DATETIME | | | | 0 | | | Y | -+---------------+--------------------+---------------------------------------+-----------------+----------+-------------+-----------------+--------------+------------------+----------------+-------------+---------+------------+------------+-----------+----------------+-------------------------+-------------+------------+-----------------+----------+----------------+---------------+-----------+ ++++++++++++++++++++++++++ +|table_catalog|table_schema|table_name|table_type|table_id|data_length|max_data_length|index_length|max_index_length|avg_row_length|engine|version|row_format|table_rows|data_free|auto_increment|create_time|update_time|check_time|table_collation|checksum|create_options|table_comment|temporary| ++++++++++++++++++++++++++ +|greptime|information_schema|build_info|LOCALTEMPORARY|8|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|character_sets|LOCALTEMPORARY|9|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|check_constraints|LOCALTEMPORARY|12|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|cluster_info|LOCALTEMPORARY|31|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|collation_character_set_applicability|LOCALTEMPORARY|11|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|collations|LOCALTEMPORARY|10|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|column_privileges|LOCALTEMPORARY|6|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|column_statistics|LOCALTEMPORARY|7|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|columns|LOCALTEMPORARY|4|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|engines|LOCALTEMPORARY|5|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|events|LOCALTEMPORARY|13|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|files|LOCALTEMPORARY|14|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|global_status|LOCALTEMPORARY|25|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|key_column_usage|LOCALTEMPORARY|16|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|optimizer_trace|LOCALTEMPORARY|17|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|parameters|LOCALTEMPORARY|18|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|partitions|LOCALTEMPORARY|28|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|profiling|LOCALTEMPORARY|19|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|referential_constraints|LOCALTEMPORARY|20|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|region_peers|LOCALTEMPORARY|29|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|routines|LOCALTEMPORARY|21|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|runtime_metrics|LOCALTEMPORARY|27|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|schema_privileges|LOCALTEMPORARY|22|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|schemata|LOCALTEMPORARY|15|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|session_status|LOCALTEMPORARY|26|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|table_constraints|LOCALTEMPORARY|30|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|table_privileges|LOCALTEMPORARY|23|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|tables|LOCALTEMPORARY|3|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|triggers|LOCALTEMPORARY|24|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|information_schema|views|LOCALTEMPORARY|32|0|0|0|0|0||11|Fixed|0|0|0|DATETIME||||0|||Y| +|greptime|public|numbers|LOCALTEMPORARY|2|0|0|0|0|0|test_engine|11|Fixed|0|0|0|DATETIME||||0|||Y| ++++++++++++++++++++++++++ select * from information_schema.columns order by table_schema, table_name, column_name; diff --git a/tests/cases/standalone/common/system/information_schema.sql b/tests/cases/standalone/common/system/information_schema.sql index 7be288c5ea..13cbe5dc9c 100644 --- a/tests/cases/standalone/common/system/information_schema.sql +++ b/tests/cases/standalone/common/system/information_schema.sql @@ -2,7 +2,8 @@ create database information_schema; -- scripts table has different table ids in different modes --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ select * from information_schema.tables where table_name != 'scripts' diff --git a/tests/cases/standalone/common/view/create.result b/tests/cases/standalone/common/view/create.result index 55902a2a5c..c1cb872111 100644 --- a/tests/cases/standalone/common/view/create.result +++ b/tests/cases/standalone/common/view/create.result @@ -64,46 +64,47 @@ SHOW FULL TABLES; +------------+-----------------+ -- SQLNESS REPLACE (\s\d+\s) ID --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ SELECT * FROM INFORMATION_SCHEMA.TABLES ORDER BY TABLE_NAME, TABLE_TYPE; -+---------------+--------------------+---------------------------------------+-----------------+----------+-------------+-----------------+--------------+------------------+----------------+-------------+---------+------------+------------+-----------+----------------+-------------------------+-------------+------------+-----------------+----------+----------------+---------------+-----------+ -| table_catalog | table_schema | table_name | table_type | table_id | data_length | max_data_length | index_length | max_index_length | avg_row_length | engine | version | row_format | table_rows | data_free | auto_increment | create_time | update_time | check_time | table_collation | checksum | create_options | table_comment | temporary | -+---------------+--------------------+---------------------------------------+-----------------+----------+-------------+-----------------+--------------+------------------+----------------+-------------+---------+------------+------------+-----------+----------------+-------------------------+-------------+------------+-----------------+----------+----------------+---------------+-----------+ -| greptime | information_schema | build_info | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | character_sets | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | check_constraints | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | cluster_info | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | collation_character_set_applicability | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | collations | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | column_privileges | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | column_statistics | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | columns | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | engines | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | events | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | files | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | global_status | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | key_column_usage | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | public | numbers | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | test_engine |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | optimizer_trace | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | parameters | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | partitions | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | profiling | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | referential_constraints | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | region_peers | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | routines | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | runtime_metrics | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | schema_privileges | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | schemata | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | session_status | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | table_constraints | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | table_privileges | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | tables | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | public | test_table | BASE TABLE |ID |ID |ID |ID |ID |ID | mito |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | N | -| greptime | public | test_view | VIEW |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | 1970-01-01T00:00:00 | | | |ID | | | N | -| greptime | information_schema | triggers | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -| greptime | information_schema | views | LOCAL TEMPORARY |ID |ID |ID |ID |ID |ID | |ID | Fixed |ID |ID |ID | DATETIME | | | |ID | | | Y | -+---------------+--------------------+---------------------------------------+-----------------+----------+-------------+-----------------+--------------+------------------+----------------+-------------+---------+------------+------------+-----------+----------------+-------------------------+-------------+------------+-----------------+----------+----------------+---------------+-----------+ ++++++++++++++++++++++++++ +|table_catalog|table_schema|table_name|table_type|table_id|data_length|max_data_length|index_length|max_index_length|avg_row_length|engine|version|row_format|table_rows|data_free|auto_increment|create_time|update_time|check_time|table_collation|checksum|create_options|table_comment|temporary| ++++++++++++++++++++++++++ +|greptime|information_schema|build_info|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|character_sets|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|check_constraints|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|cluster_info|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|collation_character_set_applicability|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|collations|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|column_privileges|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|column_statistics|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|columns|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|engines|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|events|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|files|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|global_status|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|key_column_usage|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|public|numbers|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID|test_engine|ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|optimizer_trace|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|parameters|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|partitions|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|profiling|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|referential_constraints|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|region_peers|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|routines|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|runtime_metrics|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|schema_privileges|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|schemata|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|session_status|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|table_constraints|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|table_privileges|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|tables|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|public|test_table|BASETABLE|ID|ID|ID|ID|ID|ID|mito|ID|Fixed|ID|ID|ID|DATETIME||||ID|||N| +|greptime|public|test_view|VIEW|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||N| +|greptime|information_schema|triggers|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| +|greptime|information_schema|views|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME||||ID|||Y| ++++++++++++++++++++++++++ -- SQLNESS REPLACE (\s\d+\s) ID SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'VIEW'; diff --git a/tests/cases/standalone/common/view/create.sql b/tests/cases/standalone/common/view/create.sql index e7c25c5bed..d2665249ad 100644 --- a/tests/cases/standalone/common/view/create.sql +++ b/tests/cases/standalone/common/view/create.sql @@ -28,7 +28,8 @@ SHOW TABLES; SHOW FULL TABLES; -- SQLNESS REPLACE (\s\d+\s) ID --- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}) DATETIME +-- SQLNESS REPLACE (\s[\-0-9T:\.]{15,}) DATETIME +-- SQLNESS REPLACE [\u0020\-]+ SELECT * FROM INFORMATION_SCHEMA.TABLES ORDER BY TABLE_NAME, TABLE_TYPE; -- SQLNESS REPLACE (\s\d+\s) ID diff --git a/tests/cases/standalone/optimizer/last_value.result b/tests/cases/standalone/optimizer/last_value.result new file mode 100644 index 0000000000..31f4f39a0a --- /dev/null +++ b/tests/cases/standalone/optimizer/last_value.result @@ -0,0 +1,53 @@ +create table t ( + ts timestamp time index, + host string primary key, + not_pk string, + val double, +); + +Affected Rows: 0 + +insert into t values + (0, 'a', '🌕', 1.0), + (1, 'b', '🌖', 2.0), + (2, 'a', '🌗', 3.0), + (3, 'c', '🌘', 4.0), + (4, 'a', '🌑', 5.0), + (5, 'b', '🌒', 6.0), + (6, 'a', '🌓', 7.0), + (7, 'c', '🌔', 8.0), + (8, 'd', '🌕', 9.0); + +Affected Rows: 9 + +-- SQLNESS REPLACE (metrics.*) REDACTED +-- SQLNESS REPLACE (partitioning.*) REDACTED +explain analyze + select + last_value(host order by ts), + last_value(not_pk order by ts), + last_value(val order by ts) + from t + group by host; + ++-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| stage | node | plan | ++-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 0 | 0 | MergeScanExec: peers=[5695126634496(1326, 0), ] REDACTED +| | | | +| 1 | 0 | ProjectionExec: expr=[last_value(t.host) ORDER BY [t.ts ASC NULLS LAST]@1 as last_value(t.host) ORDER BY [t.ts ASC NULLS LAST], last_value(t.not_pk) ORDER BY [t.ts ASC NULLS LAST]@2 as last_value(t.not_pk) ORDER BY [t.ts ASC NULLS LAST], last_value(t.val) ORDER BY [t.ts ASC NULLS LAST]@3 as last_value(t.val) ORDER BY [t.ts ASC NULLS LAST]] REDACTED +| | | AggregateExec: mode=FinalPartitioned, gby=[host@0 as host], aggr=[last_value(t.host) ORDER BY [t.ts ASC NULLS LAST], last_value(t.not_pk) ORDER BY [t.ts ASC NULLS LAST], last_value(t.val) ORDER BY [t.ts ASC NULLS LAST]] REDACTED +| | | CoalesceBatchesExec: target_batch_size=8192 REDACTED +| | | RepartitionExec: REDACTED +| | | CoalesceBatchesExec: target_batch_size=8192 REDACTED +| | | AggregateExec: mode=Partial, gby=[host@1 as host], aggr=[last_value(t.host) ORDER BY [t.ts ASC NULLS LAST], last_value(t.not_pk) ORDER BY [t.ts ASC NULLS LAST], last_value(t.val) ORDER BY [t.ts ASC NULLS LAST]] REDACTED +| | | RepartitionExec: REDACTED +| | | SeqScan: partition_count=1 (1 memtable ranges, 0 file ranges), selector=LastRow REDACTED +| | | | +| | | Total rows: 4 | ++-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +drop table t; + +Affected Rows: 0 + diff --git a/tests/cases/standalone/common/select/last_value.sql b/tests/cases/standalone/optimizer/last_value.sql similarity index 60% rename from tests/cases/standalone/common/select/last_value.sql rename to tests/cases/standalone/optimizer/last_value.sql index 8297a985b1..0310eb858e 100644 --- a/tests/cases/standalone/common/select/last_value.sql +++ b/tests/cases/standalone/optimizer/last_value.sql @@ -16,13 +16,14 @@ insert into t values (7, 'c', '🌔', 8.0), (8, 'd', '🌕', 9.0); --- Wait for #4354 --- explain analyze --- select --- last_value(host order by ts), --- last_value(not_pk order by ts), --- last_value(val order by ts) --- from t --- group by host; +-- SQLNESS REPLACE (metrics.*) REDACTED +-- SQLNESS REPLACE (partitioning.*) REDACTED +explain analyze + select + last_value(host order by ts), + last_value(not_pk order by ts), + last_value(val order by ts) + from t + group by host; drop table t;