Skip to content

Commit

Permalink
feat: sort the show tables/databases results
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed Jan 4, 2023
1 parent 88d1b66 commit 91bbe6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/query/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ pub fn show_databases(stmt: ShowDatabases, catalog_manager: CatalogManagerRef) -
.context(error::CatalogNotFoundSnafu {
catalog: DEFAULT_CATALOG_NAME,
})?;
let databases = catalog.schema_names().context(error::CatalogSnafu)?;
let mut databases = catalog.schema_names().context(error::CatalogSnafu)?;
// TODO(dennis): Specify the order of the results in catalog manager API
databases.sort();

let databases = if let ShowKind::Like(ident) = stmt.kind {
Helper::like_utf8(databases, &ident.value).context(error::VectorComputationSnafu)?
Expand Down Expand Up @@ -134,7 +136,9 @@ pub fn show_tables(
.schema(DEFAULT_CATALOG_NAME, &schema)
.context(error::CatalogSnafu)?
.context(error::SchemaNotFoundSnafu { schema })?;
let tables = schema.table_names().context(error::CatalogSnafu)?;
let mut tables = schema.table_names().context(error::CatalogSnafu)?;
// TODO(dennis): Specify the order of the results in schema provider API
tables.sort();

let tables = if let ShowKind::Like(ident) = stmt.kind {
Helper::like_utf8(tables, &ident.value).context(error::VectorComputationSnafu)?
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/standalone/catalog/schema.result
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ SHOW DATABASES;
+---------+
| Schemas |
+---------+
| test |
| public |
| test |
+---------+

CREATE TABLE test.hello(i BIGINT TIME INDEX);
Expand Down

0 comments on commit 91bbe6c

Please sign in to comment.