/** * Should produce the same result as * {@link org.apache.hadoop.hive.ql.io.AcidUtils#isAcidTable(org.apache.hadoop.hive.ql.metadata.Table)}. */ public static boolean isAcidTable(Table table) { return TxnUtils.isTransactionalTable(table) && TransactionalValidationListener.DEFAULT_TRANSACTIONAL_PROPERTY.equals(table.getParameters() .get(hive_metastoreConstants.TABLE_TRANSACTIONAL_PROPERTIES)); }
private Map<String, String> adjustStatsParamsForGet(Map<String, String> tableParams, Map<String, String> params, long statsWriteId, String validWriteIds) throws MetaException { if (!TxnUtils.isTransactionalTable(tableParams)) return params; // Not a txn table. if (areTxnStatsSupported && ((validWriteIds == null) || ObjectStore.isCurrentStatsValidForTheQuery( conf, params, statsWriteId, validWriteIds, false))) { // Valid stats are supported for txn tables, and either no verification was requested by the // caller, or the verification has succeeded. return params; } // Clone the map to avoid affecting the cached value. params = new HashMap<>(params); StatsSetupConst.setBasicStatsState(params, StatsSetupConst.FALSE); return params; }
void updateTableLocation(Table table, Path newLocation) throws HiveException { String msg = String.format("ALTER TABLE %s SET LOCATION '%s'", getQualifiedName(table), newLocation); LOG.info(msg); boolean isTxn = TxnUtils.isTransactionalTable(table); org.apache.hadoop.hive.ql.metadata.Table modifiedTable = new org.apache.hadoop.hive.ql.metadata.Table(table); modifiedTable.setDataLocation(newLocation); alterTableInternal(isTxn, table, modifiedTable); }
void updateTableProperties(Table table, Map<String, String> props) throws HiveException { StringBuilder sb = new StringBuilder(); boolean isTxn = TxnUtils.isTransactionalTable(table); org.apache.hadoop.hive.ql.metadata.Table modifiedTable = doFileRename ? new org.apache.hadoop.hive.ql.metadata.Table(table) : null;
@Override public PartitionFiles next() { try { Partition p = partitionIter.next(); Iterator<String> fileIterator; //For transactional tables, the actual file copy will be done by acid write event during replay of commit txn. if (!TxnUtils.isTransactionalTable(t)) { List<String> files = Lists.newArrayList(new FileIterator(p.getSd().getLocation())); fileIterator = files.iterator(); } else { fileIterator = Collections.emptyIterator(); } PartitionFiles partitionFiles = new PartitionFiles(Warehouse.makePartName(t.getPartitionKeys(), p.getValues()), fileIterator); return partitionFiles; } catch (MetaException e) { throw new RuntimeException(e); } }
private ColumnStatistics adjustColStatForGet(Map<String, String> tableParams, Map<String, String> params, ColumnStatistics colStat, long statsWriteId, String validWriteIds) throws MetaException { colStat.setIsStatsCompliant(true); if (!TxnUtils.isTransactionalTable(tableParams)) return colStat; // Not a txn table. if (areTxnStatsSupported && ((validWriteIds == null) || ObjectStore.isCurrentStatsValidForTheQuery( conf, params, statsWriteId, validWriteIds, false))) { // Valid stats are supported for txn tables, and either no verification was requested by the // caller, or the verification has succeeded. return colStat; } // Don't clone; ColStats objects are not cached, only their parts. colStat.setIsStatsCompliant(false); return colStat; }
@Override public void onDropTable(DropTableEvent tableEvent) throws MetaException { if (TxnUtils.isTransactionalTable(tableEvent.getTable())) { txnHandler = getTxnHandler(); txnHandler.cleanupRecords(HiveObjectType.TABLE, null, tableEvent.getTable(), null); } }
@Override public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException { if (TxnUtils.isTransactionalTable(partitionEvent.getTable())) { txnHandler = getTxnHandler(); txnHandler.cleanupRecords(HiveObjectType.PARTITION, null, partitionEvent.getTable(), partitionEvent.getPartitionIterator()); } }
private TxnCtx generateTxnCtxForAlter( Table table, IMetaStoreClient msc, Boolean wasTxn) throws HiveException { if ((wasTxn != null && !wasTxn) || !TxnUtils.isTransactionalTable(table.getParameters())) { return null; } try { UserGroupInformation ugi = UserGroupInformation.getCurrentUser(); long txnId = msc.openTxn(ugi == null ? "anonymous" : ugi.getShortUserName()); TxnCtx result = null; try { ValidTxnList txns = msc.getValidTxns(txnId); String fqn = table.getDbName() + "." + table.getTableName(); List<TableValidWriteIds> writeIdsObj = msc.getValidWriteIds( Lists.newArrayList(fqn), txns.toString()); String validWriteIds = TxnCommonUtils.createValidTxnWriteIdList(txnId, writeIdsObj) .getTableValidWriteIdList(fqn).writeToString(); long writeId = msc.allocateTableWriteId(txnId, table.getDbName(), table.getTableName()); result = new TxnCtx(writeId, validWriteIds, txnId); } finally { if (result == null) { msc.abortTxns(Lists.newArrayList(txnId)); } } return result; } catch (IOException | TException ex) { throw new HiveException(ex); } }
@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; }
@Override public void onAlterTable(AlterTableEvent tableEvent) throws MetaException { if (!TxnUtils.isTransactionalTable(tableEvent.getNewTable())) { return; } Table oldTable = tableEvent.getOldTable(); Table newTable = tableEvent.getNewTable(); if(!oldTable.getCatName().equalsIgnoreCase(newTable.getCatName()) || !oldTable.getDbName().equalsIgnoreCase(newTable.getDbName()) || !oldTable.getTableName().equalsIgnoreCase(newTable.getTableName())) { txnHandler = getTxnHandler(); txnHandler.onRename( oldTable.getCatName(), oldTable.getDbName(), oldTable.getTableName(), null, newTable.getCatName(), newTable.getDbName(), newTable.getTableName(), null); } } @Override
boolean isTxn = TxnUtils.isTransactionalTable(table.getParameters()); if (isTxn && !areTxnStatsSupported) { return null;
if (TxnUtils.isTransactionalTable(table)) { throw new MetaException("Cannot delete stats via this API for a transactional table");
if (TxnUtils.isTransactionalTable(table)) { throw new MetaException("Cannot delete stats via this API for a transactional table");
if (TxnUtils.isTransactionalTable(table.getParameters())) { if (!areTxnStatsSupported) {
boolean isTxn = tbl != null && TxnUtils.isTransactionalTable(tbl); if (isTxn && !areTxnStatsSupported) { StatsSetupConst.setBasicStatsState(tbl.getParameters(), StatsSetupConst.FALSE);
@Override public void onAlterPartition(AlterPartitionEvent partitionEvent) throws MetaException { if (!TxnUtils.isTransactionalTable(partitionEvent.getTable())) { return; } Partition oldPart = partitionEvent.getOldPartition(); Partition newPart = partitionEvent.getNewPartition(); Table t = partitionEvent.getTable(); String oldPartName = Warehouse.makePartName(t.getPartitionKeys(), oldPart.getValues()); String newPartName = Warehouse.makePartName(t.getPartitionKeys(), newPart.getValues()); if(!oldPartName.equals(newPartName)) { txnHandler = getTxnHandler(); txnHandler.onRename(t.getCatName(), t.getDbName(), t.getTableName(), oldPartName, t.getCatName(), t.getDbName(), t.getTableName(), newPartName); } } @Override
if (TxnUtils.isTransactionalTable(tbl)) { mtbl.setWriteId(tbl.getWriteId());
Map<String, String> newParams = new HashMap<>(table.getParameters()); StatsSetupConst.setColumnStatsState(newParams, colNames); boolean isTxn = TxnUtils.isTransactionalTable(oldt.getParameters()); if (isTxn) { if (!areTxnStatsSupported) {
boolean isTxn = TxnUtils.isTransactionalTable(table.getParameters()); if (isTxn && validWriteIds != null) { if (!areTxnStatsSupported) {