@Override
    public List<String> listTableNames(String dbName) {
        if (metastore.isPresent()) {
            List<String> allTableNames = metastore.get().getAllTableNames(dbName);
            return allTableNames.stream().filter(tableName -> {
                Table table = metastore.get().getTable(dbName, tableName);
                return table.isKuduTable();
            }).collect(Collectors.toList());
        }
        try {
            List<String> tablesList = kuduClient.getTablesList().getTablesList();
            if (!schemaEmulationEnabled && DEFAULT_SCHEMA.equals(dbName)) {
                return tablesList;
            } else if (schemaEmulationEnabled) {
                return tablesList.stream()
                        .flatMap(t -> {
                            Pair<String, String> db2table = fromRawName(t);
                            if (db2table != null && dbName.equals(db2table.first)) {
                                return ImmutableList.of(db2table.second).stream();
                            }
                            return ImmutableList.<String>of().stream();
                        })
                        .collect(Collectors.toList());
            }
            throw new StarRocksConnectorException("Database %s not exists", dbName);
        } catch (KuduException e) {
            throw new StarRocksConnectorException("Database %s not exists", dbName, e);
        }
    }
@Test
    public void testListTableNames() throws KuduException {
        KuduMetadata metadata = new KuduMetadata(KUDU_CATALOG, new HdfsEnvironment(), KUDU_MASTER,
                true, SCHEMA_EMULATION_PREFIX, Optional.empty());
        List<String> tableNames = Lists.newArrayList("impala::db1.tbl1", "db1.tbl1");
        new Expectations() {
            {
                client.getTablesList().getTablesList();
                result = tableNames;
            }
        };
        List<String> tables = metadata.listTableNames("db1");
        Assert.assertEquals(1, tables.size());
        Assert.assertEquals("tbl1", tables.get(0));
    }