mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-31 04:10:38 +00:00
chore: add optional for datatype, rename data_type to datatype (#258)
This commit is contained in:
@@ -140,7 +140,7 @@ fn create_table_schema(expr: &CreateExpr) -> Result<SchemaRef> {
|
||||
|
||||
fn create_column_schema(column_def: &ColumnDef) -> Result<ColumnSchema> {
|
||||
let data_type =
|
||||
ColumnDataTypeWrapper::try_new(column_def.data_type).context(error::ColumnDataTypeSnafu)?;
|
||||
ColumnDataTypeWrapper::try_new(column_def.datatype).context(error::ColumnDataTypeSnafu)?;
|
||||
Ok(ColumnSchema {
|
||||
name: column_def.name.clone(),
|
||||
data_type: data_type.into(),
|
||||
@@ -204,7 +204,7 @@ mod tests {
|
||||
fn test_create_column_schema() {
|
||||
let column_def = ColumnDef {
|
||||
name: "a".to_string(),
|
||||
data_type: 1024,
|
||||
datatype: 1024,
|
||||
is_nullable: true,
|
||||
};
|
||||
let result = create_column_schema(&column_def);
|
||||
@@ -216,7 +216,7 @@ mod tests {
|
||||
|
||||
let column_def = ColumnDef {
|
||||
name: "a".to_string(),
|
||||
data_type: 12, // string
|
||||
datatype: 12, // string
|
||||
is_nullable: true,
|
||||
};
|
||||
let column_schema = create_column_schema(&column_def).unwrap();
|
||||
@@ -229,22 +229,22 @@ mod tests {
|
||||
let column_defs = vec![
|
||||
ColumnDef {
|
||||
name: "host".to_string(),
|
||||
data_type: 12, // string
|
||||
datatype: 12, // string
|
||||
is_nullable: false,
|
||||
},
|
||||
ColumnDef {
|
||||
name: "ts".to_string(),
|
||||
data_type: 15, // timestamp
|
||||
datatype: 15, // timestamp
|
||||
is_nullable: false,
|
||||
},
|
||||
ColumnDef {
|
||||
name: "cpu".to_string(),
|
||||
data_type: 9, // float32
|
||||
datatype: 9, // float32
|
||||
is_nullable: true,
|
||||
},
|
||||
ColumnDef {
|
||||
name: "memory".to_string(),
|
||||
data_type: 10, // float64
|
||||
datatype: 10, // float64
|
||||
is_nullable: true,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -365,7 +365,7 @@ mod tests {
|
||||
semantic_type: SEMANTIC_TS,
|
||||
values: Some(ts_vals),
|
||||
null_mask: vec![0],
|
||||
datatype: 15,
|
||||
datatype: Some(15),
|
||||
};
|
||||
|
||||
let insert_batch = InsertBatch {
|
||||
|
||||
@@ -74,9 +74,11 @@ fn try_convert(record_batches: Vec<RecordBatch>) -> Result<SelectResult> {
|
||||
column_name,
|
||||
values: Some(values(&arrays)?),
|
||||
null_mask: null_mask(&arrays, row_count),
|
||||
datatype: ColumnDataTypeWrapper::try_from(schema.data_type.clone())
|
||||
.context(error::ColumnDataTypeSnafu)?
|
||||
.datatype() as i32,
|
||||
datatype: Some(
|
||||
ColumnDataTypeWrapper::try_from(schema.data_type.clone())
|
||||
.context(error::ColumnDataTypeSnafu)?
|
||||
.datatype() as i32,
|
||||
),
|
||||
..Default::default()
|
||||
};
|
||||
columns.push(column);
|
||||
|
||||
@@ -48,7 +48,7 @@ async fn test_insert_and_select() {
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}),
|
||||
datatype: 12, // string
|
||||
datatype: Some(12), // string
|
||||
..Default::default()
|
||||
};
|
||||
let expected_cpu_col = Column {
|
||||
@@ -58,7 +58,7 @@ async fn test_insert_and_select() {
|
||||
..Default::default()
|
||||
}),
|
||||
null_mask: vec![2],
|
||||
datatype: 10, // float64
|
||||
datatype: Some(10), // float64
|
||||
..Default::default()
|
||||
};
|
||||
let expected_mem_col = Column {
|
||||
@@ -68,7 +68,7 @@ async fn test_insert_and_select() {
|
||||
..Default::default()
|
||||
}),
|
||||
null_mask: vec![4],
|
||||
datatype: 10, // float64
|
||||
datatype: Some(10), // float64
|
||||
..Default::default()
|
||||
};
|
||||
let expected_ts_col = Column {
|
||||
@@ -77,7 +77,7 @@ async fn test_insert_and_select() {
|
||||
ts_millis_values: vec![100, 101, 102, 103],
|
||||
..Default::default()
|
||||
}),
|
||||
datatype: 15, // timestamp
|
||||
datatype: Some(15), // timestamp
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -95,7 +95,7 @@ async fn test_insert_and_select() {
|
||||
//alter
|
||||
let add_column = ColumnDef {
|
||||
name: "test_column".to_string(),
|
||||
data_type: ColumnDataType::Int64.into(),
|
||||
datatype: ColumnDataType::Int64.into(),
|
||||
is_nullable: true,
|
||||
};
|
||||
let kind = Kind::AddColumn(AddColumn {
|
||||
@@ -160,22 +160,22 @@ fn testing_create_expr() -> CreateExpr {
|
||||
let column_defs = vec![
|
||||
ColumnDef {
|
||||
name: "host".to_string(),
|
||||
data_type: 12, // string
|
||||
datatype: 12, // string
|
||||
is_nullable: false,
|
||||
},
|
||||
ColumnDef {
|
||||
name: "cpu".to_string(),
|
||||
data_type: 10, // float64
|
||||
datatype: 10, // float64
|
||||
is_nullable: true,
|
||||
},
|
||||
ColumnDef {
|
||||
name: "memory".to_string(),
|
||||
data_type: 10, // float64
|
||||
datatype: 10, // float64
|
||||
is_nullable: true,
|
||||
},
|
||||
ColumnDef {
|
||||
name: "ts".to_string(),
|
||||
data_type: 15, // timestamp
|
||||
datatype: 15, // timestamp
|
||||
is_nullable: true,
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user