From 5cb65c054067810fd72550cf4ed580de8be0180d Mon Sep 17 00:00:00 2001 From: Lilit0x Date: Sat, 16 Sep 2023 19:33:14 +0100 Subject: [PATCH] fix: handled no tabletype and error for usopprted command in show databse --- src/query/src/sql.rs | 11 +++++------ src/sql/src/statements/show.rs | 16 ---------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/query/src/sql.rs b/src/query/src/sql.rs index f788e13fda8c..9b5910276ea0 100644 --- a/src/query/src/sql.rs +++ b/src/query/src/sql.rs @@ -135,7 +135,7 @@ pub async fn show_databases( .context(error::CreateRecordBatchSnafu)?; Ok(Output::RecordBatches(records)) } - ShowKind::Full => todo!(), + ShowKind::Full => error::UnsupportedExprSnafu { name: "FULL" }.fail()?, } } @@ -186,14 +186,13 @@ pub async fn show_tables( ShowKind::Full => { let mut table_types = Vec::with_capacity(tables.len()); for table_name in &tables { - let table_type = catalog_manager + if let Some(table_type) = catalog_manager .table(query_ctx.current_catalog(), &schema_name, table_name) .await .context(error::CatalogSnafu)? - .unwrap() - .table_type(); - - table_types.push(format!("{table_type}")); + { + table_types.push(table_type.table_type().to_string()); + } } let table_types = Arc::new(StringVector::from(table_types)) as _; diff --git a/src/sql/src/statements/show.rs b/src/sql/src/statements/show.rs index b5f8e631725d..e3f7fa0b1132 100644 --- a/src/sql/src/statements/show.rs +++ b/src/sql/src/statements/show.rs @@ -140,20 +140,4 @@ mod tests { let sql = "SHOW CREATE TABLE"; assert!(ParserContext::create_with_dialect(sql, &GreptimeDbDialect {}).is_err()); } - - #[test] - pub fn test_show_full_tables() { - let sql = "SHOW FULL TABLES"; - let stmts = ParserContext::create_with_dialect(sql, &GreptimeDbDialect {}).unwrap(); - assert_eq!(1, stmts.len()); - assert_matches!(&stmts[0], Statement::ShowTables { .. }); - match &stmts[0] { - Statement::ShowTables(show) => { - assert_eq!(ShowKind::Full, show.kind); - } - _ => { - unreachable!(); - } - } - } }