diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java index 53b7a67a42..a42c3dc0bb 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java @@ -171,25 +171,6 @@ private Counter directSqlErrors; private boolean areTxnStatsSupported = false; - /** - * A Autocloseable wrapper around Query class to pass the Query object to the caller and let the caller release - * the resources when the QueryWrapper goes out of scope - */ - public static class QueryWrapper implements AutoCloseable { - public Query query; - - /** - * Explicitly closes the query object to release the resources - */ - @Override - public void close() { - if (query != null) { - query.closeAll(); - query = null; - } - } - } - public ObjectStore() { } @@ -810,21 +791,22 @@ public boolean dropDatabase(String catName, String dbname) 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); - List dbGrants = this.listDatabaseGrants(catName, dbname, null, queryWrapper); + List dbGrants = this.listDatabaseGrants(catName, dbname, null); if (CollectionUtils.isNotEmpty(dbGrants)) { pm.deletePersistentAll(dbGrants); } pm.deletePersistent(db); success = commitTransaction(); + } catch (Exception e) { + throw new MetaException(e.getMessage()); } finally { - rollbackAndCleanup(success, queryWrapper); + rollbackAndCleanup(success, null); } return success; } @@ -2719,10 +2701,11 @@ private boolean dropPartitionCommon(MPartition part) throws MetaException, return directSql.getPartitions(catName, dbName, tblName, maxParts); } @Override - protected List getJdoResult( - GetHelper> ctx) throws MetaException { - try (QueryWrapper queryWrapper = new QueryWrapper()) { - return convertToParts(listMPartitions(catName, dbName, tblName, maxParts, queryWrapper)); + protected List getJdoResult(GetHelper> ctx) throws MetaException { + try { + return convertToParts(listMPartitions(catName, dbName, tblName, maxParts)); + } catch (Exception e) { + throw new MetaException(e.getMessage()); } } }.run(false); @@ -2733,11 +2716,10 @@ private boolean dropPartitionCommon(MPartition part) throws MetaException, short max, String userName, List groupNames) throws MetaException, InvalidObjectException { boolean success = false; - QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); - List mparts = listMPartitions(catName, dbName, tblName, max, queryWrapper); + List mparts = listMPartitions(catName, dbName, tblName, max); List parts = new ArrayList<>(mparts.size()); if (CollectionUtils.isNotEmpty(mparts)) { for (MPartition mpart : mparts) { @@ -2756,8 +2738,10 @@ private boolean dropPartitionCommon(MPartition part) throws MetaException, } success = commitTransaction(); return parts; + } catch (Exception e) { + throw new MetaException(e.getMessage()); } finally { - rollbackAndCleanup(success, queryWrapper); + rollbackAndCleanup(success, null); } } @@ -3128,32 +3112,35 @@ private PartitionValuesResponse getDistinctValuesForPartitionsNoTxn( * you want results for. E.g., if resultsCol is partitionName, the Collection * has types of String, and if resultsCol is null, the types are MPartition. */ - private Collection getPartitionPsQueryResults(String catName, String dbName, String tableName, - List part_vals, short max_parts, String resultsCol, QueryWrapper queryWrapper) - throws MetaException, NoSuchObjectException { + private Collection getPartitionPsQueryResults(String catName, String dbName, String tableName, List part_vals, + short max_parts, String resultsCol) throws Exception { + + Preconditions.checkState(this.currentTransaction.isActive()); + catName = normalizeIdentifier(catName); dbName = normalizeIdentifier(dbName); tableName = normalizeIdentifier(tableName); Table table = getTable(catName, dbName, tableName, null); if (table == null) { - throw new NoSuchObjectException(TableName.getQualified(catName, dbName, tableName) - + " table not found"); + throw new NoSuchObjectException(TableName.getQualified(catName, dbName, tableName) + " table not found"); } - // size is known since it contains dbName, catName, tblName and partialRegex pattern + // size is known since it contains dbName, catName, tblName and partialRegex + // pattern Map params = new HashMap<>(4); String filter = getJDOFilterStrForPartitionVals(table, part_vals, params); - Query query = queryWrapper.query = pm.newQuery(MPartition.class); - query.setFilter(filter); - query.declareParameters(makeParameterDeclarationString(params)); - if (max_parts >= 0) { - // User specified a row limit, set it on the Query - query.setRange(0, max_parts); - } - if (resultsCol != null && !resultsCol.isEmpty()) { - query.setResult(resultsCol); - } + try (Query query = pm.newQuery(MPartition.class)) { + query.setFilter(filter); + query.declareParameters(makeParameterDeclarationString(params)); + if (max_parts >= 0) { + // User specified a row limit, set it on the Query + query.setRange(0, max_parts); + } + if (resultsCol != null && !resultsCol.isEmpty()) { + query.setResult(resultsCol); + } - return (Collection) query.executeWithMap(params); + return (Collection) query.executeWithMap(params); + } } @Override @@ -3162,13 +3149,12 @@ private Collection getPartitionPsQueryResults(String catName, String dbName, Str throws MetaException, InvalidObjectException, NoSuchObjectException { List partitions = new ArrayList<>(); boolean success = false; - QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); LOG.debug("executing listPartitionNamesPsWithAuth"); Collection parts = getPartitionPsQueryResults(catName, db_name, tbl_name, - part_vals, max_parts, null, queryWrapper); + part_vals, max_parts, null); MTable mtbl = getMTable(catName, db_name, tbl_name); for (Object o : parts) { Partition part = convertToPart((MPartition) o); @@ -3184,8 +3170,10 @@ private Collection getPartitionPsQueryResults(String catName, String dbName, Str partitions.add(part); } success = commitTransaction(); + } catch (Exception e) { + throw new MetaException(e.getMessage()); } finally { - rollbackAndCleanup(success, queryWrapper); + rollbackAndCleanup(success, null); } return partitions; } @@ -3195,91 +3183,90 @@ private Collection getPartitionPsQueryResults(String catName, String dbName, Str List part_vals, short max_parts) throws MetaException, NoSuchObjectException { List partitionNames = new ArrayList<>(); boolean success = false; - QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); LOG.debug("Executing listPartitionNamesPs"); Collection names = getPartitionPsQueryResults(catName, dbName, tableName, - part_vals, max_parts, "partitionName", queryWrapper); + part_vals, max_parts, "partitionName"); partitionNames.addAll(names); success = commitTransaction(); + } catch (Exception e) { + throw new MetaException(e.getMessage()); } finally { - rollbackAndCleanup(success, queryWrapper); + rollbackAndCleanup(success, null); } return partitionNames; } - // TODO:pc implement max - private List listMPartitions(String catName, String dbName, String tableName, - int max, QueryWrapper queryWrapper) { - boolean success = false; - List mparts = null; - try { - openTransaction(); - LOG.debug("Executing listMPartitions"); - dbName = normalizeIdentifier(dbName); - tableName = normalizeIdentifier(tableName); - Query query = queryWrapper.query = pm.newQuery(MPartition.class, - "table.tableName == t1 && table.database.name == t2 && table.database.catalogName == t3"); + private List listMPartitions(String catName, String dbName, String tableName, int max) throws Exception { + final List mparts; + + LOG.debug("Executing listMPartitions"); + + Preconditions.checkState(this.currentTransaction.isActive()); + + dbName = normalizeIdentifier(dbName); + tableName = normalizeIdentifier(tableName); + + try (Query query = pm.newQuery(MPartition.class, + "table.tableName == t1 && table.database.name == t2 && table.database.catalogName == t3")) { query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3"); query.setOrdering("partitionName ascending"); if (max >= 0) { query.setRange(0, max); } mparts = (List) query.execute(tableName, dbName, catName); - LOG.debug("Done executing query for listMPartitions"); - pm.retrieveAll(mparts); - success = commitTransaction(); - LOG.debug("Done retrieving all objects for listMPartitions {}", mparts); - } finally { - if (!success) { - rollbackTransaction(); - } } + + LOG.debug("Done executing query for listMPartitions"); + pm.retrieveAll(mparts); + LOG.debug("Done retrieving all objects for listMPartitions {}", mparts); return mparts; } // This code is only executed in JDO code path, not from direct SQL code path. - private List listMPartitionsWithProjection(QueryWrapper queryWrapper, - List fieldNames, String jdoFilter, Map params) throws MetaException { + private List listMPartitionsWithProjection(List fieldNames, String jdoFilter, + Map params) throws Exception { boolean success = false; List mparts = null; try { openTransaction(); LOG.debug("Executing listMPartitionsWithProjection"); - Query query = queryWrapper.query = pm.newQuery(MPartition.class, jdoFilter); - String parameterDeclaration = makeParameterDeclarationStringObj(params); - query.declareParameters(parameterDeclaration); - query.setOrdering("partitionName ascending"); - if (fieldNames == null || fieldNames.isEmpty()) { - // full fetch of partitions - mparts = (List) query.executeWithMap(params); - pm.retrieveAll(mparts); - } else { - // fetch partially filled partitions using result clause - query.setResult(Joiner.on(',').join(fieldNames)); - // if more than one fields are in the result class the return type is List - if (fieldNames.size() > 1) { - List results = (List) query.executeWithMap(params); - mparts = new ArrayList<>(results.size()); - for (Object[] row : results) { - MPartition mpart = new MPartition(); - int i = 0; - for (Object val : row) { - MetaStoreServerUtils.setNestedProperty(mpart, fieldNames.get(i), val, true); - i++; - } - mparts.add(mpart); - } + try (Query query = pm.newQuery(MPartition.class, jdoFilter)) { + String parameterDeclaration = makeParameterDeclarationStringObj(params); + query.declareParameters(parameterDeclaration); + query.setOrdering("partitionName ascending"); + if (fieldNames == null || fieldNames.isEmpty()) { + // full fetch of partitions + mparts = (List) query.executeWithMap(params); + pm.retrieveAll(mparts); } else { - // only one field is requested, return type is List - List results = (List) query.executeWithMap(params); - mparts = new ArrayList<>(results.size()); - for (Object row : results) { - MPartition mpart = new MPartition(); - MetaStoreServerUtils.setNestedProperty(mpart, fieldNames.get(0), row, true); - mparts.add(mpart); + // fetch partially filled partitions using result clause + query.setResult(Joiner.on(',').join(fieldNames)); + // if more than one fields are in the result class the return type is + // List + if (fieldNames.size() > 1) { + List results = (List) query.executeWithMap(params); + mparts = new ArrayList<>(results.size()); + for (Object[] row : results) { + MPartition mpart = new MPartition(); + int i = 0; + for (Object val : row) { + MetaStoreServerUtils.setNestedProperty(mpart, fieldNames.get(i), val, true); + i++; + } + mparts.add(mpart); + } + } else { + // only one field is requested, return type is List + List results = (List) query.executeWithMap(params); + mparts = new ArrayList<>(results.size()); + for (Object row : results) { + MPartition mpart = new MPartition(); + MetaStoreServerUtils.setNestedProperty(mpart, fieldNames.get(0), row, true); + mparts.add(mpart); + } } } } @@ -4034,9 +4021,10 @@ private void initExpressionTree() throws MetaException { params.put("t2", normalizeIdentifier(dbName)); params.put("t3", normalizeIdentifier(catName)); } - try (QueryWrapper queryWrapper = new QueryWrapper()) { - return convertToParts( - listMPartitionsWithProjection(queryWrapper, fieldNames, jdoFilter, params)); + try { + return convertToParts(listMPartitionsWithProjection(fieldNames, jdoFilter, params)); + } catch (Exception e) { + throw new RuntimeException(e); } } }.run(true); @@ -5438,7 +5426,6 @@ private MRoleMap getMSecurityUserRoleMap(String userName, PrincipalType principa public boolean removeRole(String roleName) throws MetaException, NoSuchObjectException { boolean success = false; - QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); MRole mRol = getMRole(roleName); @@ -5451,54 +5438,56 @@ public boolean removeRole(String roleName) throws MetaException, pm.deletePersistentAll(roleMap); } List roleMember = listMSecurityPrincipalMembershipRole(mRol - .getRoleName(), PrincipalType.ROLE, queryWrapper); + .getRoleName(), PrincipalType.ROLE); if (CollectionUtils.isNotEmpty(roleMember)) { pm.deletePersistentAll(roleMember); } - queryWrapper.close(); + // then remove all the grants List userGrants = listPrincipalMGlobalGrants( mRol.getRoleName(), PrincipalType.ROLE); if (CollectionUtils.isNotEmpty(userGrants)) { pm.deletePersistentAll(userGrants); } + List dbGrants = listPrincipalAllDBGrant(mRol - .getRoleName(), PrincipalType.ROLE, queryWrapper); + .getRoleName(), PrincipalType.ROLE); if (CollectionUtils.isNotEmpty(dbGrants)) { pm.deletePersistentAll(dbGrants); } - queryWrapper.close(); + List tabPartGrants = listPrincipalAllTableGrants( - mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); + mRol.getRoleName(), PrincipalType.ROLE); if (CollectionUtils.isNotEmpty(tabPartGrants)) { pm.deletePersistentAll(tabPartGrants); } - queryWrapper.close(); + List partGrants = listPrincipalAllPartitionGrants( - mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); + mRol.getRoleName(), PrincipalType.ROLE); if (CollectionUtils.isNotEmpty(partGrants)) { pm.deletePersistentAll(partGrants); } - queryWrapper.close(); + List tblColumnGrants = listPrincipalAllTableColumnGrants( - mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); + mRol.getRoleName(), PrincipalType.ROLE); if (CollectionUtils.isNotEmpty(tblColumnGrants)) { pm.deletePersistentAll(tblColumnGrants); } - queryWrapper.close(); + List partColumnGrants = listPrincipalAllPartitionColumnGrants( - mRol.getRoleName(), PrincipalType.ROLE, queryWrapper); + mRol.getRoleName(), PrincipalType.ROLE); if (CollectionUtils.isNotEmpty(partColumnGrants)) { pm.deletePersistentAll(partColumnGrants); } - queryWrapper.close(); // finally remove the role pm.deletePersistent(mRol); } success = commitTransaction(); + } catch (Exception e) { + throw new MetaException(e.getMessage()); } finally { - rollbackAndCleanup(success, queryWrapper); + rollbackAndCleanup(success, null); } return success; } @@ -5616,25 +5605,20 @@ private void getAllRoleAncestors(Set processedRoleNames, List } private List listMSecurityPrincipalMembershipRole(final String roleName, - final PrincipalType principalType, - QueryWrapper queryWrapper) { - boolean success = false; - List mRoleMemebership = null; - try { - LOG.debug("Executing listMSecurityPrincipalMembershipRole"); + final PrincipalType principalType) throws Exception { + final List mRoleMemebership; + LOG.debug("Executing listMSecurityPrincipalMembershipRole"); - openTransaction(); - Query query = queryWrapper.query = pm.newQuery(MRoleMap.class, "principalName == t1 && principalType == t2"); + Preconditions.checkState(this.currentTransaction.isActive()); + + try (Query query = pm.newQuery(MRoleMap.class, "principalName == t1 && principalType == t2")) { query.declareParameters("java.lang.String t1, java.lang.String t2"); mRoleMemebership = (List) query.execute(roleName, principalType.toString()); - pm.retrieveAll(mRoleMemebership); - success = commitTransaction(); - LOG.debug("Done retrieving all objects for listMSecurityPrincipalMembershipRole"); - } finally { - if (!success) { - rollbackTransaction(); - } } + + pm.retrieveAll(mRoleMemebership); + + LOG.debug("Done retrieving all objects for listMSecurityPrincipalMembershipRole"); return mRoleMemebership; } @@ -6512,7 +6496,11 @@ public boolean refreshPrivileges(HiveObjectRef objToRefresh, String authorizer, getDefaultCatalog(conf); switch (objToRefresh.getObjectType()) { case DATABASE: - grants = this.listDBGrantsAll(catName, objToRefresh.getDbName(), authorizer); + try { + grants = this.listDBGrantsAll(catName, objToRefresh.getDbName(), authorizer); + } catch (Exception e) { + throw new MetaException(e.getMessage()); + } break; case TABLE: grants = listTableGrantsAll(catName, objToRefresh.getDbName(), objToRefresh.getObjectName(), authorizer); @@ -6802,22 +6790,25 @@ protected String describeResult() { } @Override - public List listPrincipalDBGrantsAll( - String principalName, PrincipalType principalType) { - try (QueryWrapper queryWrapper = new QueryWrapper()) { - return convertDB(listPrincipalAllDBGrant(principalName, principalType, queryWrapper)); + public List listPrincipalDBGrantsAll(String principalName, PrincipalType principalType) { + try { + return convertDB(listPrincipalAllDBGrant(principalName, principalType)); + } catch (Exception e) { + throw new RuntimeException(e); } } @Override public List listDBGrantsAll(String catName, String dbName) { - return listDBGrantsAll(catName, dbName, null); + try { + return listDBGrantsAll(catName, dbName, null); + } catch (Exception e) { + throw new RuntimeException(e); + } } - private List listDBGrantsAll(String catName, String dbName, String authorizer) { - try (QueryWrapper queryWrapper = new QueryWrapper()) { - return convertDB(listDatabaseGrants(catName, dbName, authorizer, queryWrapper)); - } + private List listDBGrantsAll(String catName, String dbName, String authorizer) throws Exception { + return convertDB(listDatabaseGrants(catName, dbName, authorizer)); } private List convertDB(List privs) { @@ -6839,34 +6830,26 @@ protected String describeResult() { return result; } - private List listPrincipalAllDBGrant(String principalName, - PrincipalType principalType, - QueryWrapper queryWrapper) { - boolean success = false; - Query query = null; - List mSecurityDBList = null; - try { - LOG.debug("Executing listPrincipalAllDBGrant"); + private List listPrincipalAllDBGrant(String principalName, PrincipalType principalType) + throws Exception { + final List mSecurityDBList; - openTransaction(); - if (principalName != null && principalType != null) { - query = queryWrapper.query = pm.newQuery(MDBPrivilege.class, "principalName == t1 && principalType == t2"); + LOG.debug("Executing listPrincipalAllDBGrant"); + + Preconditions.checkState(this.currentTransaction.isActive()); + + if (principalName != null && principalType != null) { + try (Query query = pm.newQuery(MDBPrivilege.class, "principalName == t1 && principalType == t2")) { query.declareParameters("java.lang.String t1, java.lang.String t2"); - mSecurityDBList = - (List) query.execute(principalName, principalType.toString()); - } else { - query = queryWrapper.query = pm.newQuery(MDBPrivilege.class); - mSecurityDBList = (List) query.execute(); + mSecurityDBList = (List) query.execute(principalName, principalType.toString()); } - pm.retrieveAll(mSecurityDBList); - success = commitTransaction(); - - LOG.debug("Done retrieving all objects for listPrincipalAllDBGrant"); - } finally { - if (!success) { - rollbackTransaction(); + } else { + try (Query query = pm.newQuery(MDBPrivilege.class)) { + mSecurityDBList = (List) query.execute(); } } + pm.retrieveAll(mSecurityDBList); + LOG.debug("Done retrieving all objects for listPrincipalAllDBGrant"); return mSecurityDBList; } @@ -7043,36 +7026,32 @@ private void dropPartitionAllColumnGrantsNoTxn( queryWithParams.getLeft().deletePersistentAll(queryWithParams.getRight()); } - private List listDatabaseGrants(String catName, String dbName, - String authorizer, QueryWrapper queryWrapper) { + private List listDatabaseGrants(String catName, String dbName, String authorizer) throws Exception { + LOG.debug("Executing listDatabaseGrants"); + + Preconditions.checkState(currentTransaction.isActive()); + dbName = normalizeIdentifier(dbName); catName = normalizeIdentifier(catName); - boolean success = false; - try { - LOG.debug("Executing listDatabaseGrants"); - openTransaction(); - List mSecurityDBList = null; - if (authorizer != null) { - Query query = queryWrapper.query = pm.newQuery(MDBPrivilege.class, - "database.name == t1 && database.catalogName == t2 && authorizer == t3"); + final List mSecurityDBList; + + if (authorizer != null) { + try (Query query = + pm.newQuery(MDBPrivilege.class, "database.name == t1 && database.catalogName == t2 && authorizer == t3")) { query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3"); mSecurityDBList = (List) query.executeWithArray(dbName, catName, authorizer); - } else { - Query query = queryWrapper.query = pm.newQuery(MDBPrivilege.class, - "database.name == t1 && database.catalogName == t2"); + } + } else { + try (Query query = pm.newQuery(MDBPrivilege.class, "database.name == t1 && database.catalogName == t2")) { query.declareParameters("java.lang.String t1, java.lang.String t2"); mSecurityDBList = (List) query.executeWithArray(dbName, catName); } - pm.retrieveAll(mSecurityDBList); - success = commitTransaction(); - LOG.debug("Done retrieving all objects for listDatabaseGrants"); - return mSecurityDBList; - } finally { - if (!success) { - rollbackTransaction(); - } } + + pm.retrieveAll(mSecurityDBList); + LOG.debug("Done retrieving all objects for listDatabaseGrants"); + return mSecurityDBList; } private List listPartitionGrants(String catName, String dbName, String tableName, @@ -7550,28 +7529,22 @@ private void dropPartitionGrantsNoTxn(String catName, String dbName, String tabl return result; } - private List listPrincipalAllTableGrants( - String principalName, PrincipalType principalType, QueryWrapper queryWrapper) { - boolean success = false; - List mSecurityTabPartList = null; - try { - LOG.debug("Executing listPrincipalAllTableGrants"); + private List listPrincipalAllTableGrants(String principalName, PrincipalType principalType) + throws Exception { + final List mSecurityTabPartList; - openTransaction(); - Query query = queryWrapper.query = pm.newQuery(MTablePrivilege.class, - "principalName == t1 && principalType == t2"); - query.declareParameters("java.lang.String t1, java.lang.String t2"); - mSecurityTabPartList = (List) query.execute( - principalName, principalType.toString()); - pm.retrieveAll(mSecurityTabPartList); - success = commitTransaction(); + LOG.debug("Executing listPrincipalAllTableGrants"); - LOG.debug("Done retrieving all objects for listPrincipalAllTableGrants"); - } finally { - if (!success) { - rollbackTransaction(); - } + Preconditions.checkState(this.currentTransaction.isActive()); + + try (Query query = pm.newQuery(MTablePrivilege.class, "principalName == t1 && principalType == t2")) { + query.declareParameters("java.lang.String t1, java.lang.String t2"); + mSecurityTabPartList = (List) query.execute(principalName, principalType.toString()); } + + pm.retrieveAll(mSecurityTabPartList); + + LOG.debug("Done retrieving all objects for listPrincipalAllTableGrants"); return mSecurityTabPartList; } @@ -7664,25 +7637,22 @@ private void dropPartitionGrantsNoTxn(String catName, String dbName, String tabl return result; } - private List listPrincipalAllPartitionGrants(String principalName, - PrincipalType principalType, QueryWrapper queryWrapper) { - boolean success = false; - List mSecurityTabPartList = null; - try { - openTransaction(); - LOG.debug("Executing listPrincipalAllPartitionGrants"); - Query query = queryWrapper.query = pm.newQuery(MPartitionPrivilege.class, "principalName == t1 && principalType == t2"); + private List listPrincipalAllPartitionGrants(String principalName, PrincipalType principalType) + throws Exception { + final List mSecurityTabPartList; + + LOG.debug("Executing listPrincipalAllPartitionGrants"); + + Preconditions.checkState(this.currentTransaction.isActive()); + + try (Query query = pm.newQuery(MPartitionPrivilege.class, "principalName == t1 && principalType == t2")) { query.declareParameters("java.lang.String t1, java.lang.String t2"); - mSecurityTabPartList = - (List) query.execute(principalName, principalType.toString()); - pm.retrieveAll(mSecurityTabPartList); - success = commitTransaction(); - LOG.debug("Done retrieving all objects for listPrincipalAllPartitionGrants"); - } finally { - if (!success) { - rollbackTransaction(); - } + mSecurityTabPartList = (List) query.execute(principalName, principalType.toString()); } + + pm.retrieveAll(mSecurityTabPartList); + LOG.debug("Done retrieving all objects for listPrincipalAllPartitionGrants"); + return mSecurityTabPartList; } @@ -7766,28 +7736,21 @@ private void dropPartitionGrantsNoTxn(String catName, String dbName, String tabl } private List listPrincipalAllTableColumnGrants(String principalName, - PrincipalType principalType, QueryWrapper queryWrapper) { - boolean success = false; + PrincipalType principalType) throws Exception { - List mSecurityColumnList = null; - try { - LOG.debug("Executing listPrincipalAllTableColumnGrants"); + LOG.debug("Executing listPrincipalAllTableColumnGrants"); - openTransaction(); - Query query = queryWrapper.query = - pm.newQuery(MTableColumnPrivilege.class, "principalName == t1 && principalType == t2"); - query.declareParameters("java.lang.String t1, java.lang.String t2"); - mSecurityColumnList = - (List) query.execute(principalName, principalType.toString()); - pm.retrieveAll(mSecurityColumnList); - success = commitTransaction(); + Preconditions.checkState(this.currentTransaction.isActive()); - LOG.debug("Done retrieving all objects for listPrincipalAllTableColumnGrants"); - } finally { - if (!success) { - rollbackTransaction(); - } + final List mSecurityColumnList; + try (Query query = pm.newQuery(MTableColumnPrivilege.class, "principalName == t1 && principalType == t2")) { + query.declareParameters("java.lang.String t1, java.lang.String t2"); + mSecurityColumnList = (List) query.execute(principalName, principalType.toString()); } + + pm.retrieveAll(mSecurityColumnList); + LOG.debug("Done retrieving all objects for listPrincipalAllTableColumnGrants"); + return mSecurityColumnList; } @@ -7873,28 +7836,22 @@ private void dropPartitionGrantsNoTxn(String catName, String dbName, String tabl return result; } - private List listPrincipalAllPartitionColumnGrants( - String principalName, PrincipalType principalType, QueryWrapper queryWrapper) { - boolean success = false; - List mSecurityColumnList = null; - try { - LOG.debug("Executing listPrincipalAllTableColumnGrants"); + private List listPrincipalAllPartitionColumnGrants(String principalName, + PrincipalType principalType) throws Exception { + final List mSecurityColumnList; - openTransaction(); - Query query = queryWrapper.query = - pm.newQuery(MPartitionColumnPrivilege.class, "principalName == t1 && principalType == t2"); - query.declareParameters("java.lang.String t1, java.lang.String t2"); - mSecurityColumnList = - (List) query.execute(principalName, principalType.toString()); - pm.retrieveAll(mSecurityColumnList); - success = commitTransaction(); + LOG.debug("Executing listPrincipalAllTableColumnGrants"); - LOG.debug("Done retrieving all objects for listPrincipalAllTableColumnGrants"); - } finally { - if (!success) { - rollbackTransaction(); - } + Preconditions.checkState(this.currentTransaction.isActive()); + + try (Query query = pm.newQuery(MPartitionColumnPrivilege.class, "principalName == t1 && principalType == t2")) { + query.declareParameters("java.lang.String t1, java.lang.String t2"); + mSecurityColumnList = (List) query.execute(principalName, principalType.toString()); } + + pm.retrieveAll(mSecurityColumnList); + LOG.debug("Done retrieving all objects for listPrincipalAllTableColumnGrants"); + return mSecurityColumnList; } @@ -7978,19 +7935,20 @@ private String getPartitionStr(Table tbl, Map partName) throws In * is used by HiveMetaTool. This API **shouldn't** be exposed via Thrift. * */ - public Collection executeJDOQLSelect(String queryStr, QueryWrapper queryWrapper) { + public Collection executeJDOQLSelect(String queryStr) throws Exception { boolean committed = false; Collection result = null; try { openTransaction(); - Query query = queryWrapper.query = pm.newQuery(queryStr); - result = ((Collection) query.execute()); - committed = commitTransaction(); + try (Query query = pm.newQuery(queryStr)) { + result = ((Collection) query.execute()); + committed = commitTransaction(); - if (committed) { - return result; - } else { - return null; + if (committed) { + return result; + } else { + return null; + } } } finally { if (!committed) { @@ -8006,22 +7964,22 @@ private String getPartitionStr(Table tbl, Map partName) throws In * is used by HiveMetaTool. This API **shouldn't** be exposed via Thrift. * */ - public long executeJDOQLUpdate(String queryStr) { + public long executeJDOQLUpdate(String queryStr) throws Exception { boolean committed = false; long numUpdated = 0; - Query query = null; try { openTransaction(); - query = pm.newQuery(queryStr); - numUpdated = (Long) query.execute(); - committed = commitTransaction(); - if (committed) { - return numUpdated; - } else { - return -1; + try (Query query = pm.newQuery(queryStr)) { + numUpdated = (Long) query.execute(); + committed = commitTransaction(); + if (committed) { + return numUpdated; + } else { + return -1; + } } } finally { - rollbackAndCleanup(committed, query); + rollbackAndCleanup(committed, null); } } @@ -8457,21 +8415,19 @@ private void writeMTableColumnStatistics(Table table, MTableColumnStatistics mSt MTableColumnStatistics oldStats) throws MetaException { String colName = mStatsObj.getColName(); - try (QueryWrapper queryWrapper = new QueryWrapper()) { - LOG.info("Updating table level column statistics for table={}" + - " colName={}", Warehouse.getCatalogQualifiedTableName(table), colName); - validateTableCols(table, Lists.newArrayList(colName)); + LOG.info("Updating table level column statistics for table={}" + " colName={}", + Warehouse.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); + 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); } } @@ -8500,17 +8456,15 @@ private void writeMPartitionColumnStatistics(Table table, Partition partition, LOG.warn("Column " + colName + " for which stats gathering is requested doesn't exist."); } - try (QueryWrapper queryWrapper = new QueryWrapper()) { - 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); + 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); } } @@ -8519,15 +8473,12 @@ private void writeMPartitionColumnStatistics(Table table, Partition partition, * * @return Map of column name and its stats */ - private Map getPartitionColStats(Table table, - List colNames, String engine) throws MetaException { + private Map getPartitionColStats(Table table, List colNames, String engine) + throws MetaException { Map statsMap = Maps.newHashMap(); - try (QueryWrapper queryWrapper = new QueryWrapper()) { - List stats = getMTableColumnStatistics(table, - colNames, engine, queryWrapper); - for(MTableColumnStatistics cStat : stats) { - statsMap.put(cStat.getColName(), cStat); - } + List stats = getMTableColumnStatistics(table, colNames, engine); + for (MTableColumnStatistics cStat : stats) { + statsMap.put(cStat.getColName(), cStat); } return statsMap; } @@ -8609,12 +8560,10 @@ private void writeMPartitionColumnStatistics(Table table, Partition partition, private Map getPartitionColStats(Table table, String partitionName, List colNames, String engine) throws NoSuchObjectException, MetaException { Map statsMap = Maps.newHashMap(); - try (QueryWrapper queryWrapper = new QueryWrapper()) { - List stats = getMPartitionColumnStatistics(table, - Lists.newArrayList(partitionName), colNames, engine, queryWrapper); - for(MPartitionColumnStatistics cStat : stats) { - statsMap.put(cStat.getColName(), cStat); - } + List stats = + getMPartitionColumnStatistics(table, Lists.newArrayList(partitionName), colNames, engine); + for (MPartitionColumnStatistics cStat : stats) { + statsMap.put(cStat.getColName(), cStat); } return statsMap; } @@ -8689,8 +8638,10 @@ private void writeMPartitionColumnStatistics(Table table, Partition partition, } } - private List getMTableColumnStatistics(Table table, List colNames, String engine, QueryWrapper queryWrapper) + private List getMTableColumnStatistics(Table table, List colNames, String engine) throws MetaException { + final List result; + if (colNames == null || colNames.isEmpty()) { return Collections.emptyList(); } @@ -8700,38 +8651,36 @@ private void writeMPartitionColumnStatistics(Table table, Partition partition, openTransaction(); validateTableCols(table, colNames); - Query query = queryWrapper.query = pm.newQuery(MTableColumnStatistics.class); - List result = - Batchable.runBatched(batchSize, colNames, new Batchable() { - @Override - public List run(List input) - throws MetaException { - StringBuilder filter = - new StringBuilder("tableName == t1 && dbName == t2 && catName == t3 && engine == t4 && ("); - StringBuilder paramStr = new StringBuilder( - "java.lang.String t1, java.lang.String t2, java.lang.String t3, java.lang.String t4"); - Object[] params = new Object[input.size() + 4]; - params[0] = table.getTableName(); - params[1] = table.getDbName(); - params[2] = table.getCatName(); - params[3] = engine; - for (int i = 0; i < input.size(); ++i) { - filter.append((i == 0) ? "" : " || ").append("colName == c").append(i); - paramStr.append(", java.lang.String c").append(i); - params[i + 4] = input.get(i); - } - filter.append(")"); - query.setFilter(filter.toString()); - query.declareParameters(paramStr.toString()); - List paritial = (List) query.executeWithArray(params); - pm.retrieveAll(paritial); - return paritial; + try (Query query = pm.newQuery(MTableColumnStatistics.class)) { + result = Batchable.runBatched(batchSize, colNames, new Batchable() { + @Override + public List run(List input) throws MetaException { + StringBuilder filter = + new StringBuilder("tableName == t1 && dbName == t2 && catName == t3 && engine == t4 && ("); + StringBuilder paramStr = + new StringBuilder("java.lang.String t1, java.lang.String t2, java.lang.String t3, java.lang.String t4"); + Object[] params = new Object[input.size() + 4]; + params[0] = table.getTableName(); + params[1] = table.getDbName(); + params[2] = table.getCatName(); + params[3] = engine; + for (int i = 0; i < input.size(); ++i) { + filter.append((i == 0) ? "" : " || ").append("colName == c").append(i); + paramStr.append(", java.lang.String c").append(i); + params[i + 4] = input.get(i); } - }); + filter.append(")"); + query.setFilter(filter.toString()); + query.declareParameters(paramStr.toString()); + List paritial = (List) query.executeWithArray(params); + pm.retrieveAll(paritial); + return paritial; + } + }); - if (result.size() > colNames.size()) { - throw new MetaException("Unexpected " + result.size() + " statistics for " - + colNames.size() + " columns"); + if (result.size() > colNames.size()) { + throw new MetaException("Unexpected " + result.size() + " statistics for " + colNames.size() + " columns"); + } } committed = commitTransaction(); return result; @@ -8852,26 +8801,26 @@ protected ColumnStatistics getSqlResult(GetHelper ctx) throws protected ColumnStatistics getJdoResult( GetHelper ctx) throws MetaException { - try (QueryWrapper queryWrapper = new QueryWrapper()) { - List mStats = getMTableColumnStatistics(getTable(), colNames, engine, 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 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(); + List mStats = getMTableColumnStatistics(getTable(), colNames, engine); + 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 statObjs = new ArrayList<>(mStats.size()); + for (MTableColumnStatistics mStat : mStats) { + if (desc.getLastAnalyzed() > mStat.getLastAnalyzed()) { + desc.setLastAnalyzed(mStat.getLastAnalyzed()); } - ColumnStatistics colStat = new ColumnStatistics(desc, statObjs); - colStat.setEngine(engine); - return colStat; + statObjs.add(StatObjectConverter.getTableColumnStatisticsObj(mStat, enableBitVector)); + Deadline.checkTimeout(); } + ColumnStatistics colStat = new ColumnStatistics(desc, statObjs); + colStat.setEngine(engine); + return colStat; } }.run(true); } @@ -8968,36 +8917,33 @@ protected ColumnStatistics getJdoResult( @Override protected List getJdoResult( GetHelper> ctx) throws MetaException, NoSuchObjectException { - try (QueryWrapper queryWrapper = new QueryWrapper()) { - List mStats = - getMPartitionColumnStatistics(getTable(), partNames, colNames, engine, queryWrapper); - List result = new ArrayList<>( - Math.min(mStats.size(), partNames.size())); - String lastPartName = null; - List curList = null; - ColumnStatisticsDesc csd = null; - for (int i = 0; i <= mStats.size(); ++i) { - boolean isLast = i == mStats.size(); - MPartitionColumnStatistics mStatsObj = isLast ? null : mStats.get(i); - String partName = isLast ? null : mStatsObj.getPartitionName(); - if (isLast || !partName.equals(lastPartName)) { - if (i != 0) { - ColumnStatistics colStat = new ColumnStatistics(csd, curList); - colStat.setEngine(engine); - result.add(colStat); - } - if (isLast) { - continue; - } - csd = StatObjectConverter.getPartitionColumnStatisticsDesc(mStatsObj); - curList = new ArrayList<>(colNames.size()); + List mStats = + getMPartitionColumnStatistics(getTable(), partNames, colNames, engine); + List result = new ArrayList<>(Math.min(mStats.size(), partNames.size())); + String lastPartName = null; + List curList = null; + ColumnStatisticsDesc csd = null; + for (int i = 0; i <= mStats.size(); ++i) { + boolean isLast = i == mStats.size(); + MPartitionColumnStatistics mStatsObj = isLast ? null : mStats.get(i); + String partName = isLast ? null : mStatsObj.getPartitionName(); + if (isLast || !partName.equals(lastPartName)) { + if (i != 0) { + ColumnStatistics colStat = new ColumnStatistics(csd, curList); + colStat.setEngine(engine); + result.add(colStat); } - curList.add(StatObjectConverter.getPartitionColumnStatisticsObj(mStatsObj, enableBitVector)); - lastPartName = partName; - Deadline.checkTimeout(); + if (isLast) { + continue; + } + csd = StatObjectConverter.getPartitionColumnStatisticsDesc(mStatsObj); + curList = new ArrayList<>(colNames.size()); } - return result; + curList.add(StatObjectConverter.getPartitionColumnStatisticsObj(mStatsObj, enableBitVector)); + lastPartName = partName; + Deadline.checkTimeout(); } + return result; } }.run(true); } @@ -9107,9 +9053,9 @@ public void flushCache() { // NOP as there's no caching } - private List getMPartitionColumnStatistics( - Table table, List partNames, List colNames, String engine, QueryWrapper queryWrapper) - throws MetaException { + private List getMPartitionColumnStatistics(Table table, List partNames, + List colNames, String engine) throws MetaException { + final List result; boolean committed = false; try { @@ -9121,34 +9067,34 @@ public void flushCache() { } catch (MetaException me) { LOG.warn("The table does not have the same column definition as its partition."); } - Query query = queryWrapper.query = pm.newQuery(MPartitionColumnStatistics.class); - String paramStr = "java.lang.String t1, java.lang.String t2, java.lang.String t3, java.lang.String t4"; - String filter = "tableName == t1 && dbName == t2 && catName == t3 && engine == t4 && ("; - Object[] params = new Object[colNames.size() + partNames.size() + 4]; - int i = 0; - params[i++] = table.getTableName(); - params[i++] = table.getDbName(); - params[i++] = table.isSetCatName() ? table.getCatName() : getDefaultCatalog(conf); - params[i++] = engine; - int firstI = i; - for (String s : partNames) { - filter += ((i == firstI) ? "" : " || ") + "partitionName == p" + i; - paramStr += ", java.lang.String p" + i; - params[i++] = s; - } - filter += ") && ("; - firstI = i; - for (String s : colNames) { - filter += ((i == firstI) ? "" : " || ") + "colName == c" + i; - paramStr += ", java.lang.String c" + i; - params[i++] = s; - } - filter += ")"; - query.setFilter(filter); - query.declareParameters(paramStr); - query.setOrdering("partitionName ascending"); - List result = - (List) query.executeWithArray(params); + try (Query query = pm.newQuery(MPartitionColumnStatistics.class)) { + String paramStr = "java.lang.String t1, java.lang.String t2, java.lang.String t3, java.lang.String t4"; + String filter = "tableName == t1 && dbName == t2 && catName == t3 && engine == t4 && ("; + Object[] params = new Object[colNames.size() + partNames.size() + 4]; + int i = 0; + params[i++] = table.getTableName(); + params[i++] = table.getDbName(); + params[i++] = table.isSetCatName() ? table.getCatName() : getDefaultCatalog(conf); + params[i++] = engine; + int firstI = i; + for (String s : partNames) { + filter += ((i == firstI) ? "" : " || ") + "partitionName == p" + i; + paramStr += ", java.lang.String p" + i; + params[i++] = s; + } + filter += ") && ("; + firstI = i; + for (String s : colNames) { + filter += ((i == firstI) ? "" : " || ") + "colName == c" + i; + paramStr += ", java.lang.String c" + i; + params[i++] = s; + } + filter += ")"; + query.setFilter(filter); + query.declareParameters(paramStr); + query.setOrdering("partitionName ascending"); + result = (List) query.executeWithArray(params); + } pm.retrieveAll(result); committed = commitTransaction(); return result; @@ -11427,26 +11373,6 @@ void rollbackAndCleanup(boolean success, Query query) { } } - /** - * 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 checkForConstraintException(Exception e, String msg) throws AlreadyExistsException { if (getConstraintException(e) != null) { LOG.error(msg, e); diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/metatool/MetaToolTaskExecuteJDOQLQuery.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/metatool/MetaToolTaskExecuteJDOQLQuery.java index 394b5dc107..a6b6939969 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/metatool/MetaToolTaskExecuteJDOQLQuery.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/metatool/MetaToolTaskExecuteJDOQLQuery.java @@ -21,38 +21,38 @@ import java.util.Collection; import java.util.Iterator; -import org.apache.hadoop.hive.metastore.ObjectStore; - class MetaToolTaskExecuteJDOQLQuery extends MetaToolTask { @Override void execute() { String query = getCl().getJDOQLQuery(); - if (query.toLowerCase().trim().startsWith("select")) { - executeJDOQLSelect(query); - } else if (query.toLowerCase().trim().startsWith("update")) { - executeJDOQLUpdate(query); - } else { - throw new IllegalArgumentException("HiveMetaTool:Unsupported statement type, only select and update supported"); + try { + if (query.toLowerCase().trim().startsWith("select")) { + executeJDOQLSelect(query); + } else if (query.toLowerCase().trim().startsWith("update")) { + executeJDOQLUpdate(query); + } else { + throw new IllegalArgumentException("HiveMetaTool:Unsupported statement type, only select and update supported"); + } + } catch (Exception e) { + throw new RuntimeException(e); } } - private void executeJDOQLSelect(String query) { + private void executeJDOQLSelect(String query) throws Exception { System.out.println("Executing query: " + query); - try (ObjectStore.QueryWrapper queryWrapper = new ObjectStore.QueryWrapper()) { - Collection result = getObjectStore().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"); + Collection result = getObjectStore().executeJDOQLSelect(query); + 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"); } } - private void executeJDOQLUpdate(String query) { + private void executeJDOQLUpdate(String query) throws Exception { System.out.println("Executing query: " + query); long numUpdated = getObjectStore().executeJDOQLUpdate(query); if (numUpdated >= 0) { diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/metatool/TestMetaToolTaskExecuteJDOQLQuery.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/metatool/TestMetaToolTaskExecuteJDOQLQuery.java index 7976a5e957..1bf3483d56 100644 --- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/metatool/TestMetaToolTaskExecuteJDOQLQuery.java +++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/metatool/TestMetaToolTaskExecuteJDOQLQuery.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hive.metastore.tools.metatool; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.when; @@ -61,7 +60,7 @@ public void testSelectQuery() throws Exception { ObjectStore mockObjectStore = Mockito.mock(ObjectStore.class); doReturn(Arrays.asList(entry1, entry2)) - .when(mockObjectStore).executeJDOQLSelect(eq(selectQuery), any(ObjectStore.QueryWrapper.class)); + .when(mockObjectStore).executeJDOQLSelect(eq(selectQuery)); MetaToolTaskExecuteJDOQLQuery t = new MetaToolTaskExecuteJDOQLQuery(); t.setCommandLine(new HiveMetaToolCommandLine(new String[] {"-executeJDOQL", selectQuery}));