diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java index 47e2e6fc60..dad2d356cb 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java @@ -390,8 +390,7 @@ public Database getDatabase(String dbName) throws MetaException{ * @param tableType Table type, or null if we want to get all tables * @return list of table names */ - public List getTables(String db_name, TableType tableType) throws MetaException { - List ret = new ArrayList(); + public List getTables(String dbName, TableType tableType) throws MetaException { String queryText = "SELECT " + TBLS + ".\"TBL_NAME\"" + " FROM " + TBLS + " " + " INNER JOIN " + DBS + " ON " + TBLS + ".\"DB_ID\" = " + DBS + ".\"DB_ID\" " @@ -399,51 +398,35 @@ public Database getDatabase(String dbName) throws MetaException{ + (tableType == null ? "" : "AND " + TBLS + ".\"TBL_TYPE\" = ? ") ; List pms = new ArrayList(); - pms.add(db_name); + pms.add(dbName); if (tableType != null) { pms.add(tableType.toString()); } Query queryParams = pm.newQuery("javax.jdo.query.SQL", queryText); - List sqlResult = ensureList(executeWithArray( - queryParams, pms.toArray(), queryText)); - - if (!sqlResult.isEmpty()) { - for (Object[] line : sqlResult) { - ret.add(extractSqlString(line[0])); - } - } - return ret; + return executeWithArray( + queryParams, pms.toArray(), queryText); } /** * Get table names by using direct SQL queries. * * @param dbName Metastore database namme - * @param tableType Table type, or null if we want to get all tables * @return list of table names */ - public List getMaterializedViewsForRewriting(String db_name) throws MetaException { - List ret = new ArrayList(); + public List getMaterializedViewsForRewriting(String dbName) throws MetaException { String queryText = "SELECT " + TBLS + ".\"TBL_NAME\"" + " FROM " + TBLS + " " + " INNER JOIN " + DBS + " ON " + TBLS + ".\"DB_ID\" = " + DBS + ".\"DB_ID\" " + " WHERE " + DBS + ".\"NAME\" = ? AND " + TBLS + ".\"TBL_TYPE\" = ? " ; List pms = new ArrayList(); - pms.add(db_name); + pms.add(dbName); pms.add(TableType.MATERIALIZED_VIEW.toString()); Query queryParams = pm.newQuery("javax.jdo.query.SQL", queryText); - List sqlResult = ensureList(executeWithArray( - queryParams, pms.toArray(), queryText)); - - if (!sqlResult.isEmpty()) { - for (Object[] line : sqlResult) { - ret.add(extractSqlString(line[0])); - } - } - return ret; + return executeWithArray( + queryParams, pms.toArray(), queryText); } /**