Skip to content

Commit

Permalink
fix: handled no tabletype and error for usopprted command in show dat…
Browse files Browse the repository at this point in the history
…abse
  • Loading branch information
Lilit0x committed Sep 16, 2023
1 parent 6c6fb11 commit 5cb65c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
11 changes: 5 additions & 6 deletions src/query/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?,
}
}

Expand Down Expand Up @@ -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 _;
Expand Down
16 changes: 0 additions & 16 deletions src/sql/src/statements/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
}
}
}
}

0 comments on commit 5cb65c0

Please sign in to comment.