feat: add table info (#323)

* refactor: add table_info method for Table trait

* feat: add table_info method to Table trait

* test: add more unit test

* fix: impl table_info for SystemTable

* test: fix failing test
This commit is contained in:
Lei, Huang
2022-10-20 12:23:44 +08:00
committed by GitHub
parent d5800d0b60
commit 2d52f19662
27 changed files with 318 additions and 70 deletions

View File

@@ -5,6 +5,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
catalog = { path = "../catalog" }
common-error = { path = "../common/error" }
common-time = { path = "../common/time" }
datatypes = { path = "../datatypes" }

View File

@@ -7,6 +7,7 @@ pub mod statement;
use std::str::FromStr;
use catalog::{DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME};
use common_time::Timestamp;
use datatypes::prelude::ConcreteDataType;
use datatypes::schema::{ColumnDefaultConstraint, ColumnSchema};
@@ -24,14 +25,16 @@ use crate::error::{
/// Converts maybe fully-qualified table name (`<catalog>.<schema>.<table>` or `<table>` when
/// catalog and schema are default) to tuple.
pub fn table_idents_to_full_name(
obj_name: &ObjectName,
) -> Result<(Option<String>, Option<String>, String)> {
pub fn table_idents_to_full_name(obj_name: &ObjectName) -> Result<(String, String, String)> {
match &obj_name.0[..] {
[table] => Ok((None, None, table.value.clone())),
[table] => Ok((
DEFAULT_CATALOG_NAME.to_string(),
DEFAULT_SCHEMA_NAME.to_string(),
table.value.clone(),
)),
[catalog, schema, table] => Ok((
Some(catalog.value.clone()),
Some(schema.value.clone()),
catalog.value.clone(),
schema.value.clone(),
table.value.clone(),
)),
_ => error::InvalidSqlSnafu {