table/test_util/
table_info.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 datatypes::schema::SchemaRef;
16
17use crate::metadata::{TableInfo, TableInfoBuilder, TableMetaBuilder, TableType, TableVersion};
18
19pub fn test_table_info(
20    table_id: u32,
21    table_name: &str,
22    schema_name: &str,
23    catalog_name: &str,
24    schema: SchemaRef,
25) -> TableInfo {
26    let meta = TableMetaBuilder::empty()
27        .schema(schema)
28        .primary_key_indices(vec![])
29        .value_indices(vec![])
30        .engine("mito".to_string())
31        .next_column_id(0)
32        .options(Default::default())
33        .created_on(Default::default())
34        .region_numbers(vec![1])
35        .build()
36        .unwrap();
37
38    TableInfoBuilder::default()
39        .table_id(table_id)
40        .table_version(0 as TableVersion)
41        .name(table_name.to_string())
42        .schema_name(schema_name.to_string())
43        .catalog_name(catalog_name.to_string())
44        .desc(None)
45        .table_type(TableType::Base)
46        .meta(meta)
47        .build()
48        .unwrap()
49}