Skip to content

Commit

Permalink
[core] Catalog list tables sorted (#2254)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjun0x01 authored Nov 13, 2023
1 parent 1d8e592 commit 9fd5550
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.apache.paimon.options.CatalogOptions.LINEAGE_META;

Expand Down Expand Up @@ -139,7 +140,7 @@ public List<String> listTables(String databaseName) throws DatabaseNotExistExcep
throw new DatabaseNotExistException(databaseName);
}

return listTablesImpl(databaseName);
return listTablesImpl(databaseName).stream().sorted().collect(Collectors.toList());
}

protected abstract List<String> listTablesImpl(String databaseName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,16 @@ public void testConflictOption() {
"Can not set changelog-producer on table without primary keys");
}

@Test
public void testShowTablesSorted() {
spark.sql("create table t3(id int, name string)");
spark.sql("create table t4(id int, name string)");
List<Row> tables = spark.sql("SHOW TABLES").collectAsList();
assertThat(tables.toString())
.isEqualTo(
"[[default,t1,false], [default,t2,false], [default,t3,false], [default,t4,false]]");
}

@Test
public void testCreateTableWithNullablePk() {
spark.sql(
Expand Down

0 comments on commit 9fd5550

Please sign in to comment.