Skip to content

Commit

Permalink
feat: avoid confusion in desc table (GreptimeTeam#2272)
Browse files Browse the repository at this point in the history
feat: Field to Column to aviod confusion in DESC TABLE
  • Loading branch information
fengjiachun authored and paomian committed Oct 19, 2023
1 parent f7c0518 commit 6fbbf0b
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 162 deletions.
2 changes: 1 addition & 1 deletion src/query/src/sql.rs
Expand Up @@ -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";
Expand Down
50 changes: 25 additions & 25 deletions tests-integration/src/tests/instance_test.rs
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
42 changes: 21 additions & 21 deletions tests/cases/standalone/common/alter/alter_table.result
Expand Up @@ -4,26 +4,26 @@ 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;

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;
Expand All @@ -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;

Expand Down
140 changes: 70 additions & 70 deletions tests/cases/standalone/common/alter/alter_table_first_after.result
Expand Up @@ -4,52 +4,52 @@ 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;

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;

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);

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -124,36 +124,36 @@ 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;

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;

Expand Down
24 changes: 12 additions & 12 deletions tests/cases/standalone/common/alter/rename_table.result
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6fbbf0b

Please sign in to comment.