/** * Return true if the current statistics in the Metastore is valid * for the query of the given "txnId" and "queryValidWriteIdList". * * Note that a statistics entity is valid iff * the stats is written by the current query or * the conjunction of the following two are true: * ~ COLUMN_STATE_ACCURATE(CSA) state is true * ~ Isolation-level (snapshot) compliant with the query * @param tbl MTable of the stats entity * @param queryValidWriteIdList valid writeId list of the query * @Precondition "tbl" should be retrieved from the TBLS table. */ private boolean isCurrentStatsValidForTheQuery(MTable tbl, String queryValidWriteIdList, boolean isCompleteStatsWriter) throws MetaException { return isCurrentStatsValidForTheQuery(conf, tbl.getParameters(), tbl.getWriteId(), queryValidWriteIdList, isCompleteStatsWriter); }
table.getDatabase().getName(), table.getTableName(), table.getTableType()); metaData.setCatName(catName); metaData.setComments(table.getParameters().get("comment")); metas.add(metaData);
@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); } }
"TRUE".equalsIgnoreCase(mtbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl .getPartitionKeys()), part.getValues());
mTbl.getParameters());
@Override public ColumnStatistics getTableColumnStatistics( String catName, String dbName, String tableName, List<String> colNames, String writeIdList) throws MetaException, NoSuchObjectException { // If the current stats in the metastore doesn't comply with // the isolation level of the query, set No to the compliance flag. Boolean isCompliant = null; if (writeIdList != null) { MTable table = this.getMTable(catName, dbName, tableName); isCompliant = !TxnUtils.isTransactionalTable(table.getParameters()) || (areTxnStatsSupported && isCurrentStatsValidForTheQuery(table, writeIdList, false)); } ColumnStatistics stats = getTableColumnStatisticsInternal( catName, dbName, tableName, colNames, true, true); if (stats != null && isCompliant != null) { stats.setIsStatsCompliant(isCompliant); } return stats; }
MTable mtbl = mpart.getTable(); part = convertToPart(mpart); if ("TRUE".equalsIgnoreCase(mtbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl .getPartitionKeys()), partVals);
List<MTableColumnPrivilege> tabColumnGrants = null; MTable table = this.getMTable(catName, dbName, tblName); if ("TRUE".equalsIgnoreCase(table.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { tabGrants = this.listAllTableGrants(catName, dbName, tblName); tabColumnGrants = this.listTableAllColumnGrants(catName, dbName, tblName);
if (TxnUtils.isTransactionalTable(table.getParameters())) { if (!areTxnStatsSupported) {
List<MTablePrivilege> tabGrants = null; List<MTableColumnPrivilege> tabColumnGrants = null; if ("TRUE".equalsIgnoreCase(table.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { tabGrants = this.listAllTableGrants(catName, part.getDbName(), part.getTableName()); tabColumnGrants = this.listTableAllColumnGrants(
Map<String, String> newParams = new HashMap<>(table.getParameters()); StatsSetupConst.setColumnStatsState(newParams, colNames); boolean isTxn = TxnUtils.isTransactionalTable(oldt.getParameters()); if (isTxn) { if (!areTxnStatsSupported) { } else { String errorMsg = verifyStatsChangeCtx( oldt.getParameters(), newParams, writeId, validWriteIds, true); if (errorMsg != null) { throw new MetaException(errorMsg);
} else if (Boolean.parseBoolean(mtbl.getParameters().get("EXTERNAL"))) { tableType = TableType.EXTERNAL_TABLE.toString(); } else { .getOwner(), mtbl.getCreateTime(), mtbl.getLastAccessTime(), mtbl .getRetention(), convertToStorageDescriptor(mtbl.getSd()), convertToFieldSchemas(mtbl.getPartitionKeys()), convertMap(mtbl.getParameters()), mtbl.getViewOriginalText(), mtbl.getViewExpandedText(), tableType);
oldt.setTableName(normalizeIdentifier(newt.getTableName())); boolean isTxn = TxnUtils.isTransactionalTable(newTable); boolean isToTxn = isTxn && !TxnUtils.isTransactionalTable(oldt.getParameters()); if (!isToTxn && isTxn && areTxnStatsSupported) { String errorMsg = verifyStatsChangeCtx(oldt.getParameters(), newTable.getParameters(), newTable.getWriteId(), queryValidWriteIds, false); if (errorMsg != null) { oldt.setParameters(newt.getParameters()); oldt.setOwner(newt.getOwner()); oldt.setOwnerType(newt.getOwnerType()); StatsSetupConst.setBasicStatsState(oldt.getParameters(), StatsSetupConst.FALSE); } else if (queryValidWriteIds != null && newTable.getWriteId() > 0) { StatsSetupConst.setBasicStatsState(oldt.getParameters(), StatsSetupConst.FALSE); LOG.info("Removed COLUMN_STATS_ACCURATE from the parameters of the table " + dbname + "." + name + ". will be made persistent.");
List<MTableColumnPrivilege> tabColumnGrants = null; MTable table = this.getMTable(catName, dbName, tblName); if ("TRUE".equalsIgnoreCase(table.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { tabGrants = this.listAllTableGrants(catName, dbName, tblName); tabColumnGrants = this.listTableAllColumnGrants(catName, dbName, tblName);
boolean isTxn = TxnUtils.isTransactionalTable(table.getParameters()); if (isTxn && areTxnStatsSupported) {
MTable mtbl = mpart.getTable(); part = convertToPart(mpart); if ("TRUE".equalsIgnoreCase(mtbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl .getPartitionKeys()), partVals);
private Table convertToTable(MTable mtbl) throws MetaException { if (mtbl == null) { return null; } String tableType = mtbl.getTableType(); if (tableType == null) { // for backwards compatibility with old metastore persistence if (mtbl.getViewOriginalText() != null) { tableType = TableType.VIRTUAL_VIEW.toString(); } else if ("TRUE".equals(mtbl.getParameters().get("EXTERNAL"))) { tableType = TableType.EXTERNAL_TABLE.toString(); } else { tableType = TableType.MANAGED_TABLE.toString(); } } return new Table(mtbl.getTableName(), mtbl.getDatabase().getName(), mtbl .getOwner(), mtbl.getCreateTime(), mtbl.getLastAccessTime(), mtbl .getRetention(), convertToStorageDescriptor(mtbl.getSd()), convertToFieldSchemas(mtbl.getPartitionKeys()), mtbl.getParameters(), mtbl.getViewOriginalText(), mtbl.getViewExpandedText(), tableType); }
private Table convertToTable(MTable mtbl) throws MetaException { if (mtbl == null) { return null; } String tableType = mtbl.getTableType(); if (tableType == null) { // for backwards compatibility with old metastore persistence if (mtbl.getViewOriginalText() != null) { tableType = TableType.VIRTUAL_VIEW.toString(); } else if ("TRUE".equals(mtbl.getParameters().get("EXTERNAL"))) { tableType = TableType.EXTERNAL_TABLE.toString(); } else { tableType = TableType.MANAGED_TABLE.toString(); } } return new Table(mtbl.getTableName(), mtbl.getDatabase().getName(), mtbl .getOwner(), mtbl.getCreateTime(), mtbl.getLastAccessTime(), mtbl .getRetention(), convertToStorageDescriptor(mtbl.getSd()), convertToFieldSchemas(mtbl.getPartitionKeys()), convertMap(mtbl.getParameters()), mtbl.getViewOriginalText(), mtbl.getViewExpandedText(), tableType); }
private Table convertToTable(MTable mtbl) throws MetaException { if (mtbl == null) { return null; } String tableType = mtbl.getTableType(); if (tableType == null) { // for backwards compatibility with old metastore persistence if (mtbl.getViewOriginalText() != null) { tableType = TableType.VIRTUAL_VIEW.toString(); } else if ("TRUE".equals(mtbl.getParameters().get("EXTERNAL"))) { tableType = TableType.EXTERNAL_TABLE.toString(); } else { tableType = TableType.MANAGED_TABLE.toString(); } } return new Table(mtbl.getTableName(), mtbl.getDatabase().getName(), mtbl .getOwner(), mtbl.getCreateTime(), mtbl.getLastAccessTime(), mtbl .getRetention(), convertToStorageDescriptor(mtbl.getSd()), convertToFieldSchemas(mtbl.getPartitionKeys()), mtbl.getParameters(), mtbl.getViewOriginalText(), mtbl.getViewExpandedText(), tableType); }
private Table convertToTable(MTable mtbl) throws MetaException { if (mtbl == null) { return null; } String tableType = mtbl.getTableType(); if (tableType == null) { // for backwards compatibility with old metastore persistence if (mtbl.getViewOriginalText() != null) { tableType = TableType.VIRTUAL_VIEW.toString(); } else if ("TRUE".equals(mtbl.getParameters().get("EXTERNAL"))) { tableType = TableType.EXTERNAL_TABLE.toString(); } else { tableType = TableType.MANAGED_TABLE.toString(); } } return new Table(mtbl.getTableName(), mtbl.getDatabase().getName(), mtbl .getOwner(), mtbl.getCreateTime(), mtbl.getLastAccessTime(), mtbl .getRetention(), convertToStorageDescriptor(mtbl.getSd()), convertToFieldSchemas(mtbl.getPartitionKeys()), convertMap(mtbl.getParameters()), mtbl.getViewOriginalText(), mtbl.getViewExpandedText(), tableType); }