feat: avoid confusion in desc table (#2272)

feat: Field to Column to aviod confusion in DESC TABLE
This commit is contained in:
JeremyHi
2023-08-28 19:50:33 +08:00
committed by GitHub
parent c112b9a763
commit c02ac36ce8
9 changed files with 162 additions and 162 deletions

View File

@@ -47,7 +47,7 @@ use crate::error::{self, Result};
const SCHEMAS_COLUMN: &str = "Schemas";
const TABLES_COLUMN: &str = "Tables";
const COLUMN_NAME_COLUMN: &str = "Field";
const COLUMN_NAME_COLUMN: &str = "Column";
const COLUMN_TYPE_COLUMN: &str = "Type";
const COLUMN_KEY_COLUMN: &str = "Key";
const COLUMN_NULLABLE_COLUMN: &str = "Null";

View File

@@ -551,7 +551,7 @@ async fn test_execute_query_external_table_parquet(instance: Arc<dyn MockInstanc
let output = execute_sql(&instance, &format!("desc table {table_name};")).await;
let expect = "\
+------------+-----------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
| Column | Type | Key | Null | Default | Semantic Type |
+------------+-----------------+-----+------+---------+---------------+
| c_int | Int64 | | YES | | FIELD |
| c_float | Float64 | | YES | | FIELD |
@@ -616,7 +616,7 @@ async fn test_execute_query_external_table_orc(instance: Arc<dyn MockInstance>)
let output = execute_sql(&instance, &format!("desc table {table_name};")).await;
let expect = "\
+------------------------+---------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
| Column | Type | Key | Null | Default | Semantic Type |
+------------------------+---------------------+-----+------+---------+---------------+
| double_a | Float64 | | YES | | FIELD |
| a | Float32 | | YES | | FIELD |
@@ -691,7 +691,7 @@ async fn test_execute_query_external_table_csv(instance: Arc<dyn MockInstance>)
let output = execute_sql(&instance, &format!("desc table {table_name};")).await;
let expect = "\
+------------+-----------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
| Column | Type | Key | Null | Default | Semantic Type |
+------------+-----------------+-----+------+---------+---------------+
| c_int | Int64 | | YES | | FIELD |
| c_float | Float64 | | YES | | FIELD |
@@ -736,17 +736,17 @@ async fn test_execute_query_external_table_json(instance: Arc<dyn MockInstance>)
let output = execute_sql(&instance, &format!("desc table {table_name};")).await;
let expect = "\
+-------+---------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+---------+-----+------+---------+---------------+
| a | Int64 | | YES | | FIELD |
| b | Float64 | | YES | | FIELD |
| c | Boolean | | YES | | FIELD |
| d | String | | YES | | FIELD |
| e | Int64 | | YES | | FIELD |
| f | String | | YES | | FIELD |
| g | String | | YES | | FIELD |
+-------+---------+-----+------+---------+---------------+";
+--------+---------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+---------+-----+------+---------+---------------+
| a | Int64 | | YES | | FIELD |
| b | Float64 | | YES | | FIELD |
| c | Boolean | | YES | | FIELD |
| d | String | | YES | | FIELD |
| e | Int64 | | YES | | FIELD |
| f | String | | YES | | FIELD |
| g | String | | YES | | FIELD |
+--------+---------+-----+------+---------+---------------+";
check_output_stream(output, expect).await;
let output = execute_sql(&instance, &format!("select * from {table_name};")).await;
@@ -796,17 +796,17 @@ async fn test_execute_query_external_table_json_with_schame(instance: Arc<dyn Mo
let output = execute_sql(&instance, &format!("desc table {table_name};")).await;
let expect = "\
+-------+-----------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-----------------+-----+------+---------+---------------+
| a | Int64 | | YES | | FIELD |
| b | Float64 | | YES | | FIELD |
| c | Boolean | | YES | | FIELD |
| d | String | | YES | | FIELD |
| e | TimestampSecond | | YES | | FIELD |
| f | Float64 | | YES | | FIELD |
| g | TimestampSecond | | YES | | FIELD |
+-------+-----------------+-----+------+---------+---------------+";
+--------+-----------------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-----------------+-----+------+---------+---------------+
| a | Int64 | | YES | | FIELD |
| b | Float64 | | YES | | FIELD |
| c | Boolean | | YES | | FIELD |
| d | String | | YES | | FIELD |
| e | TimestampSecond | | YES | | FIELD |
| f | Float64 | | YES | | FIELD |
| g | TimestampSecond | | YES | | FIELD |
+--------+-----------------+-----+------+---------+---------------+";
check_output_stream(output, expect).await;
let output = execute_sql(&instance, &format!("select * from {table_name};")).await;

View File

@@ -4,12 +4,12 @@ Affected Rows: 0
DESC TABLE test_alt_table;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+--------+-------+-----+------+---------+---------------+
ALTER TABLE test_alt_table ADD COLUMN k INTEGER;
@@ -17,13 +17,13 @@ Affected Rows: 0
DESC TABLE test_alt_table;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
+--------+-------+-----+------+---------+---------------+
-- SQLNESS ARG restart=true
ALTER TABLE test_alt_table ADD COLUMN m INTEGER;
@@ -32,14 +32,14 @@ Affected Rows: 0
DESC TABLE test_alt_table;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+--------+-------+-----+------+---------+---------------+
DROP TABLE test_alt_table;

View File

@@ -4,12 +4,12 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+--------+-------+-----+------+---------+---------------+
ALTER TABLE t ADD COLUMN k INTEGER;
@@ -17,24 +17,24 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
+--------+-------+-----+------+---------+---------------+
-- SQLNESS ARG restart=true
DESC TABLE t;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
+--------+-------+-----+------+---------+---------------+
ALTER TABLE t ADD COLUMN m INTEGER;
@@ -42,14 +42,14 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+--------+-------+-----+------+---------+---------------+
INSERT INTO t VALUES (1, 2, 3, 4);
@@ -69,15 +69,15 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| n | Int32 | | YES | | FIELD |
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| n | Int32 | | YES | | FIELD |
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+--------+-------+-----+------+---------+---------------+
SELECT * FROM t;
@@ -97,16 +97,16 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| n | Int32 | | YES | | FIELD |
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| y | Int32 | | YES | | FIELD |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| n | Int32 | | YES | | FIELD |
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| y | Int32 | | YES | | FIELD |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+--------+-------+-----+------+---------+---------------+
SELECT * FROM t;
@@ -124,17 +124,17 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| a | Int32 | | YES | | FIELD |
| n | Int32 | | YES | | FIELD |
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| y | Int32 | | YES | | FIELD |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| a | Int32 | | YES | | FIELD |
| n | Int32 | | YES | | FIELD |
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| y | Int32 | | YES | | FIELD |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+--------+-------+-----+------+---------+---------------+
ALTER TABLE t ADD COLUMN b INTEGER AFTER j;
@@ -142,18 +142,18 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| a | Int32 | | YES | | FIELD |
| n | Int32 | | YES | | FIELD |
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| b | Int32 | | YES | | FIELD |
| y | Int32 | | YES | | FIELD |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| a | Int32 | | YES | | FIELD |
| n | Int32 | | YES | | FIELD |
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
| b | Int32 | | YES | | FIELD |
| y | Int32 | | YES | | FIELD |
| k | Int32 | | YES | | FIELD |
| m | Int32 | | YES | | FIELD |
+--------+-------+-----+------+---------+---------------+
SELECT * FROM t;

View File

@@ -4,12 +4,12 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+--------+-------+-----+------+---------+---------------+
INSERT INTO TABLE t VALUES (1, 1), (3, 3), (NULL, 4);
@@ -43,12 +43,12 @@ Affected Rows: 0
DESC TABLE new_table;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+--------+-------+-----+------+---------+---------------+
-- SQLNESS ARG restart=true
SELECT * FROM new_table;

View File

@@ -48,29 +48,29 @@ Affected Rows: 0
DESC TABLE integers;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int64 | PRI | NO | | TIMESTAMP |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int64 | PRI | NO | | TIMESTAMP |
+--------+-------+-----+------+---------+---------------+
DESC TABLE test1;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+--------+-------+-----+------+---------+---------------+
DESC TABLE test2;
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+-------+-------+-----+------+---------+---------------+
+--------+-------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+--------+-------+-----+------+---------+---------------+
DROP TABLE integers;
@@ -95,7 +95,7 @@ Affected Rows: 0
DESC TABLE test_pk;
+-----------+---------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
| Column | Type | Key | Null | Default | Semantic Type |
+-----------+---------+-----+------+---------+---------------+
| timestamp | Int64 | PRI | NO | | TIMESTAMP |
| host | String | PRI | YES | | TAG |

View File

@@ -11,7 +11,7 @@ Affected Rows: 0
describe table host_load1;
+-----------+----------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
| Column | Type | Key | Null | Default | Semantic Type |
+-----------+----------------------+-----+------+---------+---------------+
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
| collector | String | PRI | YES | | TAG |
@@ -22,7 +22,7 @@ describe table host_load1;
describe host_load1;
+-----------+----------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
| Column | Type | Key | Null | Default | Semantic Type |
+-----------+----------------------+-----+------+---------+---------------+
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
| collector | String | PRI | YES | | TAG |
@@ -33,7 +33,7 @@ describe host_load1;
desc table host_load1;
+-----------+----------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
| Column | Type | Key | Null | Default | Semantic Type |
+-----------+----------------------+-----+------+---------+---------------+
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
| collector | String | PRI | YES | | TAG |
@@ -44,7 +44,7 @@ desc table host_load1;
desc host_load1;
+-----------+----------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
| Column | Type | Key | Null | Default | Semantic Type |
+-----------+----------------------+-----+------+---------+---------------+
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
| collector | String | PRI | YES | | TAG |

View File

@@ -64,12 +64,12 @@ Affected Rows: 0
DESC TABLE test_unixtime;
+-------+----------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+----------------------+-----+------+---------+---------------+
| a | Int32 | | YES | | FIELD |
| b | TimestampMillisecond | PRI | NO | | TIMESTAMP |
+-------+----------------------+-----+------+---------+---------------+
+--------+----------------------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+----------------------+-----+------+---------+---------------+
| a | Int32 | | YES | | FIELD |
| b | TimestampMillisecond | PRI | NO | | TIMESTAMP |
+--------+----------------------+-----+------+---------+---------------+
insert into test_unixtime values(27, 27);

View File

@@ -30,11 +30,11 @@ Affected Rows: 0
desc table t3;
+-------+----------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+----------------------+-----+------+---------+---------------+
| c | TimestampMillisecond | PRI | NO | | TIMESTAMP |
+-------+----------------------+-----+------+---------+---------------+
+--------+----------------------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+----------------------+-----+------+---------+---------------+
| c | TimestampMillisecond | PRI | NO | | TIMESTAMP |
+--------+----------------------+-----+------+---------+---------------+
drop table t3;