chore: add optional for datatype, rename data_type to datatype (#258)

This commit is contained in:
fys
2022-09-14 18:07:22 +08:00
committed by GitHub
parent 0dce8946d4
commit ef40b12749
8 changed files with 48 additions and 37 deletions

View File

@@ -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,
},
];

View File

@@ -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 {

View File

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

View File

@@ -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,
},
];