feat: upgrade desc table output (#2256)

This commit is contained in:
JeremyHi
2023-08-25 14:52:22 +08:00
committed by GitHub
parent 9d87c8b6de
commit de1daec680
11 changed files with 278 additions and 262 deletions

View File

@@ -37,6 +37,6 @@ pub const INFORMATION_SCHEMA_COLUMNS_TABLE_ID: u32 = 4;
pub const MITO_ENGINE: &str = "mito";
pub const IMMUTABLE_FILE_ENGINE: &str = "file";
pub const SEMANTIC_TYPE_PRIMARY_KEY: &str = "PRIMARY KEY";
pub const SEMANTIC_TYPE_PRIMARY_KEY: &str = "TAG";
pub const SEMANTIC_TYPE_FIELD: &str = "FIELD";
pub const SEMANTIC_TYPE_TIME_INDEX: &str = "TIME INDEX";
pub const SEMANTIC_TYPE_TIME_INDEX: &str = "TIMESTAMP";

View File

@@ -49,12 +49,14 @@ const SCHEMAS_COLUMN: &str = "Schemas";
const TABLES_COLUMN: &str = "Tables";
const COLUMN_NAME_COLUMN: &str = "Field";
const COLUMN_TYPE_COLUMN: &str = "Type";
const COLUMN_KEY_COLUMN: &str = "Key";
const COLUMN_NULLABLE_COLUMN: &str = "Null";
const COLUMN_DEFAULT_COLUMN: &str = "Default";
const COLUMN_SEMANTIC_TYPE_COLUMN: &str = "Semantic Type";
const NULLABLE_YES: &str = "YES";
const NULLABLE_NO: &str = "NO";
const PRI_KEY: &str = "PRI";
static DESCRIBE_TABLE_OUTPUT_SCHEMA: Lazy<Arc<Schema>> = Lazy::new(|| {
Arc::new(Schema::new(vec![
@@ -68,6 +70,7 @@ static DESCRIBE_TABLE_OUTPUT_SCHEMA: Lazy<Arc<Schema>> = Lazy::new(|| {
ConcreteDataType::string_datatype(),
false,
),
ColumnSchema::new(COLUMN_KEY_COLUMN, ConcreteDataType::string_datatype(), true),
ColumnSchema::new(
COLUMN_NULLABLE_COLUMN,
ConcreteDataType::string_datatype(),
@@ -204,6 +207,7 @@ pub fn describe_table(table: TableRef) -> Result<Output> {
let columns = vec![
describe_column_names(columns_schemas),
describe_column_types(columns_schemas),
describe_column_keys(columns_schemas, &table_info.meta.primary_key_indices),
describe_column_nullables(columns_schemas),
describe_column_defaults(columns_schemas),
describe_column_semantic_types(columns_schemas, &table_info.meta.primary_key_indices),
@@ -225,6 +229,21 @@ fn describe_column_types(columns_schemas: &[ColumnSchema]) -> VectorRef {
))
}
fn describe_column_keys(
columns_schemas: &[ColumnSchema],
primary_key_indices: &[usize],
) -> VectorRef {
Arc::new(StringVector::from_iterator(
columns_schemas.iter().enumerate().map(|(i, cs)| {
if cs.is_time_index() || primary_key_indices.contains(&i) {
PRI_KEY
} else {
""
}
}),
))
}
fn describe_column_nullables(columns_schemas: &[ColumnSchema]) -> VectorRef {
Arc::new(StringVector::from_iterator(columns_schemas.iter().map(
|cs| {
@@ -253,20 +272,16 @@ fn describe_column_semantic_types(
columns_schemas: &[ColumnSchema],
primary_key_indices: &[usize],
) -> VectorRef {
Arc::new(StringVector::from(
columns_schemas
.iter()
.enumerate()
.map(|(i, cs)| {
if primary_key_indices.contains(&i) {
String::from(SEMANTIC_TYPE_PRIMARY_KEY)
} else if cs.is_time_index() {
String::from(SEMANTIC_TYPE_TIME_INDEX)
} else {
String::from(SEMANTIC_TYPE_FIELD)
}
})
.collect::<Vec<String>>(),
Arc::new(StringVector::from_iterator(
columns_schemas.iter().enumerate().map(|(i, cs)| {
if primary_key_indices.contains(&i) {
SEMANTIC_TYPE_PRIMARY_KEY
} else if cs.is_time_index() {
SEMANTIC_TYPE_TIME_INDEX
} else {
SEMANTIC_TYPE_FIELD
}
}),
))
}
@@ -403,6 +418,7 @@ mod test {
let expected_columns = vec![
Arc::new(StringVector::from(vec!["t1", "t2"])) as _,
Arc::new(StringVector::from(vec!["UInt32", "TimestampMillisecond"])) as _,
Arc::new(StringVector::from(vec!["", "PRI"])) as _,
Arc::new(StringVector::from(vec![NULLABLE_YES, NULLABLE_NO])) as _,
Arc::new(StringVector::from(vec!["", "current_timestamp()"])) as _,
Arc::new(StringVector::from(vec![

View File

@@ -552,16 +552,16 @@ 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 | Null | Default | Semantic Type |
+------------+-----------------+------+---------+---------------+
| c_int | Int64 | YES | | FIELD |
| c_float | Float64 | YES | | FIELD |
| c_string | Float64 | YES | | FIELD |
| c_bool | Boolean | YES | | FIELD |
| c_date | Date | YES | | FIELD |
| c_datetime | TimestampSecond | YES | | FIELD |
+------------+-----------------+------+---------+---------------+";
+------------+-----------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+------------+-----------------+-----+------+---------+---------------+
| c_int | Int64 | | YES | | FIELD |
| c_float | Float64 | | YES | | FIELD |
| c_string | Float64 | | YES | | FIELD |
| c_bool | Boolean | | YES | | FIELD |
| c_date | Date | | YES | | FIELD |
| c_datetime | TimestampSecond | | YES | | FIELD |
+------------+-----------------+-----+------+---------+---------------+";
check_output_stream(output, expect).await;
let output = execute_sql(&instance, &format!("select * from {table_name};")).await;
@@ -617,30 +617,30 @@ 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 | Null | Default | Semantic Type |
+------------------------+---------------------+------+---------+---------------+
| double_a | Float64 | YES | | FIELD |
| a | Float32 | YES | | FIELD |
| b | Boolean | YES | | FIELD |
| str_direct | String | YES | | FIELD |
| d | String | YES | | FIELD |
| e | String | YES | | FIELD |
| f | String | YES | | FIELD |
| int_short_repeated | Int32 | YES | | FIELD |
| int_neg_short_repeated | Int32 | YES | | FIELD |
| int_delta | Int32 | YES | | FIELD |
| int_neg_delta | Int32 | YES | | FIELD |
| int_direct | Int32 | YES | | FIELD |
| int_neg_direct | Int32 | YES | | FIELD |
| bigint_direct | Int64 | YES | | FIELD |
| bigint_neg_direct | Int64 | YES | | FIELD |
| bigint_other | Int64 | YES | | FIELD |
| utf8_increase | String | YES | | FIELD |
| utf8_decrease | String | YES | | FIELD |
| timestamp_simple | TimestampNanosecond | YES | | FIELD |
| date_simple | Date | YES | | FIELD |
+------------------------+---------------------+------+---------+---------------+";
+------------------------+---------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+------------------------+---------------------+-----+------+---------+---------------+
| double_a | Float64 | | YES | | FIELD |
| a | Float32 | | YES | | FIELD |
| b | Boolean | | YES | | FIELD |
| str_direct | String | | YES | | FIELD |
| d | String | | YES | | FIELD |
| e | String | | YES | | FIELD |
| f | String | | YES | | FIELD |
| int_short_repeated | Int32 | | YES | | FIELD |
| int_neg_short_repeated | Int32 | | YES | | FIELD |
| int_delta | Int32 | | YES | | FIELD |
| int_neg_delta | Int32 | | YES | | FIELD |
| int_direct | Int32 | | YES | | FIELD |
| int_neg_direct | Int32 | | YES | | FIELD |
| bigint_direct | Int64 | | YES | | FIELD |
| bigint_neg_direct | Int64 | | YES | | FIELD |
| bigint_other | Int64 | | YES | | FIELD |
| utf8_increase | String | | YES | | FIELD |
| utf8_decrease | String | | YES | | FIELD |
| timestamp_simple | TimestampNanosecond | | YES | | FIELD |
| date_simple | Date | | YES | | FIELD |
+------------------------+---------------------+-----+------+---------+---------------+";
check_output_stream(output, expect).await;
let output = execute_sql(&instance, &format!("select * from {table_name};")).await;
@@ -692,16 +692,16 @@ 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 | Null | Default | Semantic Type |
+------------+-----------------+------+---------+---------------+
| c_int | Int64 | YES | | FIELD |
| c_float | Float64 | YES | | FIELD |
| c_string | Float64 | YES | | FIELD |
| c_bool | Boolean | YES | | FIELD |
| c_date | Date | YES | | FIELD |
| c_datetime | TimestampSecond | YES | | FIELD |
+------------+-----------------+------+---------+---------------+";
+------------+-----------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+------------+-----------------+-----+------+---------+---------------+
| c_int | Int64 | | YES | | FIELD |
| c_float | Float64 | | YES | | FIELD |
| c_string | Float64 | | YES | | FIELD |
| c_bool | Boolean | | YES | | FIELD |
| c_date | Date | | YES | | FIELD |
| c_datetime | TimestampSecond | | YES | | FIELD |
+------------+-----------------+-----+------+---------+---------------+";
check_output_stream(output, expect).await;
let output = execute_sql(&instance, &format!("select * from {table_name};")).await;
@@ -738,17 +738,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 | 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 |
+-------+---------+------+---------+---------------+";
+-------+---------+-----+------+---------+---------------+
| 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 |
+-------+---------+-----+------+---------+---------------+";
check_output_stream(output, expect).await;
let output = execute_sql(&instance, &format!("select * from {table_name};")).await;
@@ -798,17 +798,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 | 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 |
+-------+-----------------+------+---------+---------------+";
+-------+-----------------+-----+------+---------+---------------+
| 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 |
+-------+-----------------+-----+------+---------+---------------+";
check_output_stream(output, expect).await;
let output = execute_sql(&instance, &format!("select * from {table_name};")).await;
@@ -1517,12 +1517,12 @@ async fn test_information_schema_dot_columns(instance: Arc<dyn MockInstance>) {
| greptime | information_schema | columns | column_name | String | FIELD |
| greptime | information_schema | columns | data_type | String | FIELD |
| greptime | information_schema | columns | semantic_type | String | FIELD |
| greptime | public | numbers | number | UInt32 | PRIMARY KEY |
| greptime | public | scripts | schema | String | PRIMARY KEY |
| greptime | public | scripts | name | String | PRIMARY KEY |
| greptime | public | numbers | number | UInt32 | TAG |
| greptime | public | scripts | schema | String | TAG |
| greptime | public | scripts | name | String | TAG |
| greptime | public | scripts | script | String | FIELD |
| greptime | public | scripts | engine | String | FIELD |
| greptime | public | scripts | timestamp | TimestampMillisecond | TIME INDEX |
| greptime | public | scripts | timestamp | TimestampMillisecond | TIMESTAMP |
| greptime | public | scripts | gmt_created | TimestampMillisecond | FIELD |
| greptime | public | scripts | gmt_modified | TimestampMillisecond | FIELD |
| greptime | information_schema | tables | table_catalog | String | FIELD |
@@ -1540,7 +1540,7 @@ async fn test_information_schema_dot_columns(instance: Arc<dyn MockInstance>) {
+-----------------+--------------------+---------------+---------------+-----------+---------------+
| table_catalog | table_schema | table_name | column_name | data_type | semantic_type |
+-----------------+--------------------+---------------+---------------+-----------+---------------+
| another_catalog | another_schema | another_table | i | Int64 | TIME INDEX |
| another_catalog | another_schema | another_table | i | Int64 | TIMESTAMP |
| another_catalog | information_schema | columns | table_catalog | String | FIELD |
| another_catalog | information_schema | columns | table_schema | String | FIELD |
| another_catalog | information_schema | columns | table_name | String | FIELD |

View File

@@ -4,12 +4,12 @@ Affected Rows: 0
DESC TABLE test_alt_table;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | 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 | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| k | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | 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 | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| k | Int32 | YES | | FIELD |
| m | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | 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 | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | 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 | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| k | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | 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 | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| k | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | 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 | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| k | Int32 | YES | | FIELD |
| m | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | 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 | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| n | Int32 | YES | | FIELD |
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| k | Int32 | YES | | FIELD |
| m | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| 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 |
+-------+-------+-----+------+---------+---------------+
SELECT * FROM t;
@@ -97,16 +97,16 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| n | Int32 | YES | | FIELD |
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| y | Int32 | YES | | FIELD |
| k | Int32 | YES | | FIELD |
| m | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| 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 |
+-------+-------+-----+------+---------+---------------+
SELECT * FROM t;
@@ -124,17 +124,17 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| a | Int32 | YES | | FIELD |
| n | Int32 | YES | | FIELD |
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| y | Int32 | YES | | FIELD |
| k | Int32 | YES | | FIELD |
| m | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| 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 |
+-------+-------+-----+------+---------+---------------+
ALTER TABLE t ADD COLUMN b INTEGER AFTER j;
@@ -142,18 +142,18 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| a | Int32 | YES | | FIELD |
| n | Int32 | YES | | FIELD |
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| b | Int32 | YES | | FIELD |
| y | Int32 | YES | | FIELD |
| k | Int32 | YES | | FIELD |
| m | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| 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 |
+-------+-------+-----+------+---------+---------------+
SELECT * FROM t;

View File

@@ -4,12 +4,12 @@ Affected Rows: 0
DESC TABLE t;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | 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 | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | 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 | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int64 | PRI | NO | | TIMESTAMP |
+-------+-------+-----+------+---------+---------------+
DESC TABLE test1;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+-------+-------+-----+------+---------+---------------+
DESC TABLE test2;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
+-------+-------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-------+-------+-----+------+---------+---------------+
| i | Int32 | | YES | | FIELD |
| j | Int64 | PRI | NO | | TIMESTAMP |
+-------+-------+-----+------+---------+---------------+
DROP TABLE integers;
@@ -94,13 +94,13 @@ Affected Rows: 0
DESC TABLE test_pk;
+-----------+---------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-----------+---------+------+---------+---------------+
| timestamp | Int64 | NO | | TIME INDEX |
| host | String | YES | | PRIMARY KEY |
| value | Float64 | YES | | FIELD |
+-----------+---------+------+---------+---------------+
+-----------+---------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-----------+---------+-----+------+---------+---------------+
| timestamp | Int64 | PRI | NO | | TIMESTAMP |
| host | String | PRI | YES | | TAG |
| value | Float64 | | YES | | FIELD |
+-----------+---------+-----+------+---------+---------------+
DROP TABLE test_pk;

View File

@@ -10,47 +10,47 @@ Affected Rows: 0
describe table host_load1;
+-----------+----------------------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-----------+----------------------+------+---------+---------------+
| ts | TimestampMillisecond | NO | | TIME INDEX |
| collector | String | YES | | PRIMARY KEY |
| host | String | YES | | PRIMARY KEY |
| val | Float64 | YES | | FIELD |
+-----------+----------------------+------+---------+---------------+
+-----------+----------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-----------+----------------------+-----+------+---------+---------------+
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
| collector | String | PRI | YES | | TAG |
| host | String | PRI | YES | | TAG |
| val | Float64 | | YES | | FIELD |
+-----------+----------------------+-----+------+---------+---------------+
describe host_load1;
+-----------+----------------------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-----------+----------------------+------+---------+---------------+
| ts | TimestampMillisecond | NO | | TIME INDEX |
| collector | String | YES | | PRIMARY KEY |
| host | String | YES | | PRIMARY KEY |
| val | Float64 | YES | | FIELD |
+-----------+----------------------+------+---------+---------------+
+-----------+----------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-----------+----------------------+-----+------+---------+---------------+
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
| collector | String | PRI | YES | | TAG |
| host | String | PRI | YES | | TAG |
| val | Float64 | | YES | | FIELD |
+-----------+----------------------+-----+------+---------+---------------+
desc table host_load1;
+-----------+----------------------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-----------+----------------------+------+---------+---------------+
| ts | TimestampMillisecond | NO | | TIME INDEX |
| collector | String | YES | | PRIMARY KEY |
| host | String | YES | | PRIMARY KEY |
| val | Float64 | YES | | FIELD |
+-----------+----------------------+------+---------+---------------+
+-----------+----------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-----------+----------------------+-----+------+---------+---------------+
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
| collector | String | PRI | YES | | TAG |
| host | String | PRI | YES | | TAG |
| val | Float64 | | YES | | FIELD |
+-----------+----------------------+-----+------+---------+---------------+
desc host_load1;
+-----------+----------------------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-----------+----------------------+------+---------+---------------+
| ts | TimestampMillisecond | NO | | TIME INDEX |
| collector | String | YES | | PRIMARY KEY |
| host | String | YES | | PRIMARY KEY |
| val | Float64 | YES | | FIELD |
+-----------+----------------------+------+---------+---------------+
+-----------+----------------------+-----+------+---------+---------------+
| Field | Type | Key | Null | Default | Semantic Type |
+-----------+----------------------+-----+------+---------+---------------+
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
| collector | String | PRI | YES | | TAG |
| host | String | PRI | YES | | TAG |
| val | Float64 | | YES | | FIELD |
+-----------+----------------------+-----+------+---------+---------------+
drop table host_load1;

View File

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

View File

@@ -29,12 +29,12 @@ select * from information_schema.columns order by table_schema, table_name;
| greptime | information_schema | tables | table_type | String | FIELD |
| greptime | information_schema | tables | table_id | UInt32 | FIELD |
| greptime | information_schema | tables | engine | String | FIELD |
| greptime | public | numbers | number | UInt32 | PRIMARY KEY |
| greptime | public | scripts | schema | String | PRIMARY KEY |
| greptime | public | scripts | name | String | PRIMARY KEY |
| greptime | public | numbers | number | UInt32 | TAG |
| greptime | public | scripts | schema | String | TAG |
| greptime | public | scripts | name | String | TAG |
| greptime | public | scripts | script | String | FIELD |
| greptime | public | scripts | engine | String | FIELD |
| greptime | public | scripts | timestamp | TimestampMillisecond | TIME INDEX |
| greptime | public | scripts | timestamp | TimestampMillisecond | TIMESTAMP |
| greptime | public | scripts | gmt_created | TimestampMillisecond | FIELD |
| greptime | public | scripts | gmt_modified | TimestampMillisecond | FIELD |
+---------------+--------------------+------------+---------------+----------------------+---------------+
@@ -89,7 +89,7 @@ order by table_schema, table_name;
+---------------+--------------+------------+-------------+-----------+---------------+
| table_catalog | table_schema | table_name | column_name | data_type | semantic_type |
+---------------+--------------+------------+-------------+-----------+---------------+
| greptime | my_db | foo | ts | Int64 | TIME INDEX |
| greptime | my_db | foo | ts | Int64 | TIMESTAMP |
+---------------+--------------+------------+-------------+-----------+---------------+
use public;

View File

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