/** * Get table names by using direct SQL queries. * * @param dbName Metastore database namme * @return list of table names */ public List<String> 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<String> pms = new ArrayList<String>(); pms.add(dbName); pms.add(TableType.MATERIALIZED_VIEW.toString()); Query<?> queryParams = pm.newQuery("javax.jdo.query.SQL", queryText); return executeWithArray( queryParams, pms.toArray(), queryText); }
/** * Get table names by using direct SQL queries. * @param catName catalog name * @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<String> getTables(String catName, String dbName, TableType tableType) throws MetaException { String queryText = "SELECT " + TBLS + ".\"TBL_NAME\"" + " FROM " + TBLS + " " + " INNER JOIN " + DBS + " ON " + TBLS + ".\"DB_ID\" = " + DBS + ".\"DB_ID\" " + " WHERE " + DBS + ".\"NAME\" = ? AND " + DBS + ".\"CTLG_NAME\" = ? " + (tableType == null ? "" : "AND " + TBLS + ".\"TBL_TYPE\" = ? ") ; List<String> pms = new ArrayList<>(); pms.add(dbName); pms.add(catName); if (tableType != null) { pms.add(tableType.toString()); } Query<?> queryParams = pm.newQuery("javax.jdo.query.SQL", queryText); return executeWithArray( queryParams, pms.toArray(), queryText); }
private boolean isViewTable(String catName, String dbName, String tblName) throws MetaException { Query query = null; try { String queryText = "select \"TBL_TYPE\" from " + TBLS + "" + " inner join " + DBS + " on " + TBLS + ".\"DB_ID\" = " + DBS + ".\"DB_ID\" " + " where " + TBLS + ".\"TBL_NAME\" = ? and " + DBS + ".\"NAME\" = ? and " + DBS + ".\"CTLG_NAME\" = ?"; Object[] params = new Object[] { tblName, dbName, catName }; query = pm.newQuery("javax.jdo.query.SQL", queryText); query.setUnique(true); Object result = executeWithArray(query, params, queryText); return (result != null) && result.toString().equals(TableType.VIRTUAL_VIEW.toString()); } finally { if (query != null) { query.closeAll(); } } }
query.setRange(0, max.shortValue()); List<Object> sqlResult = executeWithArray(query, params, queryText); long queryTime = doTrace ? System.nanoTime() : 0; MetastoreDirectSqlUtils.timingTrace(doTrace, queryText, start, queryTime);
Query<?> query = pm.newQuery("javax.jdo.query.SQL", queryText); try { List<Object[]> sqlResult = MetastoreDirectSqlUtils.ensureList(executeWithArray( query, new Object[] { dbName, catName, tableName }, queryText)); Map<String, List<String>> result = new HashMap<>();
List<Object[]> sqlResult = MetastoreDirectSqlUtils.ensureList(executeWithArray( queryParams, pms.toArray(), queryText));
List<Object[]> sqlResult = MetastoreDirectSqlUtils.ensureList(executeWithArray( queryParams, pms.toArray(), queryText));
List<Object[]> sqlResult = MetastoreDirectSqlUtils.ensureList(executeWithArray( queryParams, pms.toArray(), queryText));
List<Object[]> sqlResult = MetastoreDirectSqlUtils.ensureList(executeWithArray( queryParams, pms.toArray(), queryText));
List<Object[]> sqlResult = MetastoreDirectSqlUtils.ensureList(executeWithArray( queryParams, pms.toArray(), queryText));
private void getStatsTableListResult( String queryText, List<org.apache.hadoop.hive.common.TableName> result) throws MetaException { LOG.debug("Running {}", queryText); Query<?> query = pm.newQuery("javax.jdo.query.SQL", queryText); try { List<Object[]> sqlResult = MetastoreDirectSqlUtils .ensureList(executeWithArray(query, STATS_TABLE_TYPES, queryText)); for (Object[] line : sqlResult) { result.add(new org.apache.hadoop.hive.common.TableName( MetastoreDirectSqlUtils.extractSqlString(line[2]), MetastoreDirectSqlUtils .extractSqlString(line[1]), MetastoreDirectSqlUtils.extractSqlString(line[0]))); } } finally { query.closeAll(); } } }
try { query = pm.newQuery("javax.jdo.query.SQL", queryText); qResult = executeWithArray(query, new Object[] { dbName, catName }, queryText); if (qResult == null) { query.closeAll();
Query query = pm.newQuery("javax.jdo.query.SQL", queryText); List<Object[]> sqlResult = MetastoreDirectSqlUtils .ensureList(executeWithArray(query, null, queryText));
List<Object[]> sqlResult = MetastoreDirectSqlUtils.ensureList(executeWithArray( queryParams, pms.toArray(), queryText));
start = doTrace ? System.nanoTime() : 0; query = pm.newQuery("javax.jdo.query.SQL", queryText); qResult = executeWithArray(query, prepareParams(catName, dbName, tableName, partNames, colNames), queryText); if (qResult == null) { start = doTrace ? System.nanoTime() : 0; query = pm.newQuery("javax.jdo.query.SQL", queryText); qResult = executeWithArray(query, prepareParams(catName, dbName, tableName, partNames, colNames), queryText); end = doTrace ? System.nanoTime() : 0; start = doTrace ? System.nanoTime() : 0; query = pm.newQuery("javax.jdo.query.SQL", queryText); qResult = executeWithArray(query, prepareParams(catName, dbName, tableName, partNames, noExtraColumnNames), queryText); if (qResult == null) { List<String> extraColumnNames = new ArrayList<String>(); extraColumnNames.addAll(extraColumnNameTypeParts.keySet()); qResult = executeWithArray(query, prepareParams(catName, dbName, tableName, partNames, extraColumnNames), queryText); if (qResult == null) { qResult = executeWithArray(query, prepareParams(catName, dbName, tableName, partNames, Arrays.asList(colName)), queryText); if (qResult == null) { start = doTrace ? System.nanoTime() : 0;
List<Object[]> sqlResult = executeWithArray( queryDbSelector, params, queryTextDbSelector); if ((sqlResult == null) || sqlResult.isEmpty()) { List<Object[]> sqlResult2 = MetastoreDirectSqlUtils.ensureList(executeWithArray( queryDbParams, params, queryTextDbParams)); if (!sqlResult2.isEmpty()) {
List<Object[]> sqlResult = executeWithArray(query, null, queryText); long queryTime = doTrace ? System.nanoTime() : 0; Deadline.checkTimeout();
.ensureList(executeWithArray(query, null, queryText));
.ensureList(executeWithArray(query, null, queryText));
private boolean isViewTable(String dbName, String tblName) throws MetaException { String queryText = "select \"TBL_TYPE\" from \"TBLS\"" + " inner join \"DBS\" on \"TBLS\".\"DB_ID\" = \"DBS\".\"DB_ID\" " + " where \"TBLS\".\"TBL_NAME\" = ? and \"DBS\".\"NAME\" = ?"; Object[] params = new Object[] { tblName, dbName }; Query query = pm.newQuery("javax.jdo.query.SQL", queryText); query.setUnique(true); Object result = executeWithArray(query, params, queryText); return (result != null) && result.toString().equals(TableType.VIRTUAL_VIEW.toString()); }