use of org.apache.hadoop.hive.metastore.api.SourceTable in project hive by apache.
the class TestTxnHandler method testGetMaterializationInvalidationInfo.
private void testGetMaterializationInvalidationInfo(ValidReaderWriteIdList... tableWriteIdList) throws MetaException {
ValidTxnWriteIdList validTxnWriteIdList = new ValidTxnWriteIdList(5L);
for (ValidReaderWriteIdList tableWriteId : tableWriteIdList) {
validTxnWriteIdList.addTableValidWriteIdList(tableWriteId);
}
Table table = new Table();
table.setDbName("default");
table.setTableName("t1");
HashMap<String, String> tableParameters = new HashMap<String, String>() {
{
put(TABLE_IS_TRANSACTIONAL, "true");
put(TABLE_TRANSACTIONAL_PROPERTIES, "insert_only");
}
};
table.setParameters(tableParameters);
SourceTable sourceTable = new SourceTable();
sourceTable.setTable(table);
CreationMetadata creationMetadata = new CreationMetadata();
creationMetadata.setDbName("default");
creationMetadata.setTblName("mat1");
creationMetadata.setSourceTables(Collections.singletonList(sourceTable));
creationMetadata.setValidTxnList(validTxnWriteIdList.toString());
Materialization materialization = txnHandler.getMaterializationInvalidationInfo(creationMetadata);
assertFalse(materialization.isSourceTablesUpdateDeleteModified());
}
use of org.apache.hadoop.hive.metastore.api.SourceTable in project hive by apache.
the class HiveIncrementalRelMdRowCount method source.
public static RelMetadataProvider source(RelOptMaterialization materialization) {
MaterializedViewMetadata mvMetadata = ((RelOptHiveTable) materialization.tableRel.getTable()).getHiveTableMD().getMVMetadata();
Map<String, SourceTable> sourceTableMap = new HashMap<>(mvMetadata.getSourceTables().size());
for (SourceTable sourceTable : mvMetadata.getSourceTables()) {
Table table = sourceTable.getTable();
sourceTableMap.put(TableName.getQualified(table.getCatName(), table.getDbName(), table.getTableName()), sourceTable);
}
return ReflectiveRelMetadataProvider.reflectiveSource(BuiltInMethod.ROW_COUNT.method, new HiveIncrementalRelMdRowCount(sourceTableMap));
}
use of org.apache.hadoop.hive.metastore.api.SourceTable in project hive by apache.
the class Table method createSourceTable.
public SourceTable createSourceTable() {
SourceTable sourceTable = new SourceTable();
sourceTable.setTable(this.tTable);
sourceTable.setInsertedCount(0L);
sourceTable.setUpdatedCount(0L);
sourceTable.setDeletedCount(0L);
return sourceTable;
}
use of org.apache.hadoop.hive.metastore.api.SourceTable in project hive by apache.
the class ObjectStore method convertToSourceTable.
private SourceTable convertToSourceTable(MMVSource mmvSource, String catalogName) throws MetaException {
SourceTable sourceTable = new SourceTable();
MTable mTable = mmvSource.getTable();
Table table = getTable(catalogName, mTable.getDatabase().getName(), mTable.getTableName());
sourceTable.setTable(table);
sourceTable.setInsertedCount(mmvSource.getInsertedCount());
sourceTable.setUpdatedCount(mmvSource.getUpdatedCount());
sourceTable.setDeletedCount(mmvSource.getDeletedCount());
return sourceTable;
}
use of org.apache.hadoop.hive.metastore.api.SourceTable in project hive by apache.
the class TxnHandler method getMaterializationInvalidationInfo.
/**
* Get invalidation info for the materialization. Materialization information
* contains information about whether there was update/delete/compaction operations on the source
* tables used by the materialization since it was created.
*/
@Override
@RetrySemantics.ReadOnly
public Materialization getMaterializationInvalidationInfo(CreationMetadata creationMetadata) throws MetaException {
if (creationMetadata.getSourceTables().isEmpty()) {
// Bail out
LOG.warn("Materialization creation metadata does not contain any table");
return null;
}
boolean sourceTablesUpdateDeleteModified = false;
for (SourceTable sourceTable : creationMetadata.getSourceTables()) {
if (sourceTable.getDeletedCount() > 0 || sourceTable.getUpdatedCount() > 0) {
sourceTablesUpdateDeleteModified = true;
break;
}
}
Boolean sourceTablesCompacted = wasCompacted(creationMetadata);
if (sourceTablesCompacted == null) {
return null;
}
return new Materialization(sourceTablesUpdateDeleteModified, sourceTablesCompacted);
}
Aggregations