@Override
    public TGetTablesResult getTableNames(TGetTablesParams params) throws TException {
        LOG.debug("get table name request: {}", params);
        TGetTablesResult result = new TGetTablesResult();
        List<String> tablesResult = Lists.newArrayList();
        result.setTables(tablesResult);
        PatternMatcher matcher = null;
        boolean caseSensitive = CaseSensibility.TABLE.getCaseSensibility();
        if (params.isSetPattern()) {
            try {
                matcher = PatternMatcher.createMysqlPattern(params.getPattern(),
                        CaseSensibility.TABLE.getCaseSensibility());
            } catch (SemanticException e) {
                throw new TException("Pattern is in bad format: " + params.getPattern());
            }
        }

        // database privs should be checked in analysis phase
        String catalogName = null;
        if (params.isSetCatalog_name()) {
            catalogName = params.getCatalog_name();
        }

        MetadataMgr metadataMgr = GlobalStateMgr.getCurrentState().getMetadataMgr();
        Database db = metadataMgr.getDb(catalogName, params.db);

        UserIdentity currentUser = null;
        if (params.isSetCurrent_user_ident()) {
            currentUser = UserIdentity.fromThrift(params.current_user_ident);
        } else {
            currentUser = UserIdentity.createAnalyzedUserIdentWithIp(params.user, params.user_ip);
        }

        if (db != null) {
            for (String tableName : metadataMgr.listTableNames(catalogName, params.db)) {
                LOG.debug("get table: {}, wait to check", tableName);
                Table tbl = null;
                try {
                    tbl = metadataMgr.getTable(catalogName, params.db, tableName);
                } catch (Exception e) {
                    LOG.warn(e.getMessage(), e);
                }

                if (tbl == null) {
                    continue;
                }

                try {
                    Authorizer.checkAnyActionOnTableLikeObject(currentUser,
                            null, params.db, tbl);
                } catch (AccessDeniedException e) {
                    continue;
                }

                if (!PatternMatcher.matchPattern(params.getPattern(), tableName, matcher, caseSensitive)) {
                    continue;
                }

                tablesResult.add(tableName);
            }
        }
        return result;
    }
@Test
    public void testGetTableNames() throws TException {
        FrontendServiceImpl impl = new FrontendServiceImpl(exeEnv);
        TGetTablesParams params = new TGetTablesParams();
        params.setCatalog_name("default_catalog");
        params.setDb("test");
        TUserIdentity tUserIdentity = new TUserIdentity();
        tUserIdentity.setUsername("root");
        tUserIdentity.setHost("%");
        tUserIdentity.setIs_domain(false);
        params.setCurrent_user_ident(tUserIdentity);

        TGetTablesResult result = impl.getTableNames(params);
        Assert.assertEquals(17, result.tables.size());
    }