common_meta/ddl/test_util/
columns.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use api::v1::{ColumnDataType, ColumnDef, SemanticType};
16use derive_builder::Builder;
17
18#[derive(Default, Builder)]
19pub struct TestColumnDef {
20    #[builder(setter(into), default)]
21    name: String,
22    data_type: ColumnDataType,
23    #[builder(default)]
24    is_nullable: bool,
25    semantic_type: SemanticType,
26    #[builder(setter(into), default)]
27    comment: String,
28}
29
30impl From<TestColumnDef> for ColumnDef {
31    fn from(
32        TestColumnDef {
33            name,
34            data_type,
35            is_nullable,
36            semantic_type,
37            comment,
38        }: TestColumnDef,
39    ) -> Self {
40        Self {
41            name,
42            data_type: data_type as i32,
43            is_nullable,
44            default_constraint: vec![],
45            semantic_type: semantic_type as i32,
46            comment,
47            datatype_extension: None,
48            options: None,
49        }
50    }
51}