params.put("t3", normalizeIdentifier(catName)); try (QueryWrapper queryWrapper = new QueryWrapper()) { return convertToParts( listMPartitionsWithProjection(queryWrapper, fieldNames, jdoFilter, params));
@Override protected List<ColumnStatistics> getJdoResult( GetHelper<List<ColumnStatistics>> ctx) throws MetaException, NoSuchObjectException { QueryWrapper queryWrapper = new QueryWrapper(); try { List<MPartitionColumnStatistics> mStats = queryWrapper.close();
NoSuchObjectException { boolean success = false; QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); pm.deletePersistentAll(roleMember); queryWrapper.close(); queryWrapper.close(); List<MTablePrivilege> tabPartGrants = listPrincipalAllTableGrants( mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); queryWrapper.close(); List<MPartitionPrivilege> partGrants = listPrincipalAllPartitionGrants( mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); queryWrapper.close(); List<MTableColumnPrivilege> tblColumnGrants = listPrincipalAllTableColumnGrants( mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); queryWrapper.close(); List<MPartitionColumnPrivilege> partColumnGrants = listPrincipalAllPartitionColumnGrants( mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); queryWrapper.close();
QueryWrapper queryWrapper = new QueryWrapper(); try { if (oldStats != null) { queryWrapper.close();
@Override protected List<ColumnStatistics> getJdoResult( GetHelper<List<ColumnStatistics>> ctx) throws MetaException, NoSuchObjectException { QueryWrapper queryWrapper = new QueryWrapper(); try { List<MPartitionColumnStatistics> mStats = queryWrapper.close();
List<Partition> partitions = new ArrayList<>(); boolean success = false; QueryWrapper queryWrapper = new QueryWrapper();
@Override public List<Partition> getPartitionsWithAuth(String catName, String dbName, String tblName, short max, String userName, List<String> groupNames) throws MetaException, InvalidObjectException { boolean success = false; QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); List<MPartition> mparts = listMPartitions(catName, dbName, tblName, max, queryWrapper); List<Partition> parts = new ArrayList<>(mparts.size()); if (CollectionUtils.isNotEmpty(mparts)) { for (MPartition mpart : mparts) { MTable mtbl = mpart.getTable(); Partition part = convertToPart(mpart); parts.add(part); if ("TRUE".equalsIgnoreCase(mtbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl .getPartitionKeys()), part.getValues()); PrincipalPrivilegeSet partAuth = this.getPartitionPrivilegeSet(catName, dbName, tblName, partName, userName, groupNames); part.setPrivileges(partAuth); } } } success = commitTransaction(); return parts; } finally { rollbackAndCleanup(success, queryWrapper); } }
@Override public boolean dropDatabase(String catName, String dbname) throws NoSuchObjectException, MetaException { boolean success = false; LOG.info("Dropping database {}.{} along with all tables", catName, dbname); dbname = normalizeIdentifier(dbname); catName = normalizeIdentifier(catName); QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); // then drop the database MDatabase db = getMDatabase(catName, dbname); pm.retrieve(db); if (db != null) { List<MDBPrivilege> dbGrants = this.listDatabaseGrants(catName, dbname, null, queryWrapper); if (CollectionUtils.isNotEmpty(dbGrants)) { pm.deletePersistentAll(dbGrants); } pm.deletePersistent(db); } success = commitTransaction(); } finally { rollbackAndCleanup(success, queryWrapper); } return success; }
@Override protected ColumnStatistics getJdoResult( GetHelper<ColumnStatistics> ctx) throws MetaException { QueryWrapper queryWrapper = new QueryWrapper(); try { List<MTableColumnStatistics> mStats = getMTableColumnStatistics(getTable(), colNames, queryWrapper); if (mStats.isEmpty()) { return null; } // LastAnalyzed is stored per column, but thrift object has it per multiple columns. // Luckily, nobody actually uses it, so we will set to lowest value of all columns for now. ColumnStatisticsDesc desc = StatObjectConverter.getTableColumnStatisticsDesc(mStats.get(0)); List<ColumnStatisticsObj> statObjs = new ArrayList<>(mStats.size()); for (MTableColumnStatistics mStat : mStats) { if (desc.getLastAnalyzed() > mStat.getLastAnalyzed()) { desc.setLastAnalyzed(mStat.getLastAnalyzed()); } statObjs.add(StatObjectConverter.getTableColumnStatisticsObj(mStat, enableBitVector)); Deadline.checkTimeout(); } return new ColumnStatistics(desc, statObjs); } finally { queryWrapper.close(); } } }.run(true);
/** * Get partition's column stats * * @param table * @param partitionName * @param colNames * @return Map of column name and its stats * @throws NoSuchObjectException * @throws MetaException */ private Map<String, MPartitionColumnStatistics> getPartitionColStats(Table table, String partitionName, List<String> colNames) throws NoSuchObjectException, MetaException { Map<String, MPartitionColumnStatistics> statsMap = Maps.newHashMap(); QueryWrapper queryWrapper = new QueryWrapper(); try { List<MPartitionColumnStatistics> stats = getMPartitionColumnStatistics(table, Lists.newArrayList(partitionName), colNames, queryWrapper); for(MPartitionColumnStatistics cStat : stats) { statsMap.put(cStat.getColName(), cStat); } } finally { queryWrapper.close(); } return statsMap; }
private void writeMTableColumnStatistics(Table table, MTableColumnStatistics mStatsObj, MTableColumnStatistics oldStats) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException { String colName = mStatsObj.getColName(); QueryWrapper queryWrapper = new QueryWrapper(); try { LOG.info("Updating table level column statistics for table={}" + " colName={}", getCatalogQualifiedTableName(table), colName); validateTableCols(table, Lists.newArrayList(colName)); if (oldStats != null) { StatObjectConverter.setFieldsIntoOldStats(mStatsObj, oldStats); } else { if (sqlGenerator.getDbProduct().equals(DatabaseProduct.POSTGRES) && mStatsObj.getBitVector() == null) { // workaround for DN bug in persisting nulls in pg bytea column // instead set empty bit vector with header. mStatsObj.setBitVector(new byte[] {'H','L'}); } pm.makePersistent(mStatsObj); } } finally { queryWrapper.close(); } }
/** * Get table's column stats * * @param table * @param colNames * @return Map of column name and its stats * @throws NoSuchObjectException * @throws MetaException */ private Map<String, MTableColumnStatistics> getPartitionColStats(Table table, List<String> colNames) throws NoSuchObjectException, MetaException { Map<String, MTableColumnStatistics> statsMap = Maps.newHashMap(); QueryWrapper queryWrapper = new QueryWrapper(); try { List<MTableColumnStatistics> stats = getMTableColumnStatistics(table, colNames, queryWrapper); for(MTableColumnStatistics cStat : stats) { statsMap.put(cStat.getColName(), cStat); } } finally { queryWrapper.close(); } return statsMap; }
@Override public List<String> listPartitionNamesPs(String catName, String dbName, String tableName, List<String> part_vals, short max_parts) throws MetaException, NoSuchObjectException { List<String> partitionNames = new ArrayList<>(); boolean success = false; QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); LOG.debug("Executing listPartitionNamesPs"); Collection<String> names = getPartitionPsQueryResults(catName, dbName, tableName, part_vals, max_parts, "partitionName", queryWrapper); partitionNames.addAll(names); success = commitTransaction(); } finally { rollbackAndCleanup(success, queryWrapper); } return partitionNames; }
/** * This is a cleanup method which is used to rollback a active transaction * if the success flag is false and close the associated QueryWrapper object. This method is used * internally and visible for testing purposes only * @param success Rollback the current active transaction if false * @param queryWrapper QueryWrapper object which needs to be closed */ @VisibleForTesting void rollbackAndCleanup(boolean success, QueryWrapper queryWrapper) { try { if (!success) { rollbackTransaction(); } } finally { if (queryWrapper != null) { queryWrapper.close(); } } }
private void executeJDOQLSelect(String query) { Configuration conf = MetastoreConf.newMetastoreConf(); initObjectStore(conf); System.out.println("Executing query: " + query); try (ObjectStore.QueryWrapper queryWrapper = new ObjectStore.QueryWrapper()) { Collection<?> result = objStore.executeJDOQLSelect(query, queryWrapper); if (result != null) { Iterator<?> iter = result.iterator(); while (iter.hasNext()) { Object o = iter.next(); System.out.println(o.toString()); } } else { System.err.println("Encountered error during executeJDOQLSelect -" + "commit of JDO transaction failed."); } } }
@Override protected List<Partition> getJdoResult( GetHelper<List<Partition>> ctx) throws MetaException { QueryWrapper queryWrapper = new QueryWrapper(); try { return convertToParts(listMPartitions(catName, dbName, tblName, maxParts, queryWrapper)); } finally { queryWrapper.close(); } } }.run(false);
private List<HiveObjectPrivilege> listDBGrantsAll(String catName, String dbName, String authorizer) { QueryWrapper queryWrapper = new QueryWrapper(); try { return convertDB(listDatabaseGrants(catName, dbName, authorizer, queryWrapper)); } finally { queryWrapper.close(); } }
@Override public List<HiveObjectPrivilege> listPrincipalDBGrantsAll( String principalName, PrincipalType principalType) { QueryWrapper queryWrapper = new QueryWrapper(); try { return convertDB(listPrincipalAllDBGrant(principalName, principalType, queryWrapper)); } finally { queryWrapper.close(); } }
NoSuchObjectException { boolean success = false; QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); pm.deletePersistentAll(roleMember); queryWrapper.close(); queryWrapper.close(); List<MTablePrivilege> tabPartGrants = listPrincipalAllTableGrants( mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); queryWrapper.close(); List<MPartitionPrivilege> partGrants = listPrincipalAllPartitionGrants( mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); queryWrapper.close(); List<MTableColumnPrivilege> tblColumnGrants = listPrincipalAllTableColumnGrants( mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); queryWrapper.close(); List<MPartitionColumnPrivilege> partColumnGrants = listPrincipalAllPartitionColumnGrants( mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); queryWrapper.close();
QueryWrapper queryWrapper = new QueryWrapper(); try { if (oldStats != null) { queryWrapper.close();