Search in sources :

Example 1 with SourceTable

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());
}
Also used : Materialization(org.apache.hadoop.hive.metastore.api.Materialization) CreationMetadata(org.apache.hadoop.hive.metastore.api.CreationMetadata) SourceTable(org.apache.hadoop.hive.metastore.api.SourceTable) Table(org.apache.hadoop.hive.metastore.api.Table) HashMap(java.util.HashMap) SourceTable(org.apache.hadoop.hive.metastore.api.SourceTable) ValidTxnWriteIdList(org.apache.hadoop.hive.common.ValidTxnWriteIdList) ValidReaderWriteIdList(org.apache.hadoop.hive.common.ValidReaderWriteIdList)

Example 2 with SourceTable

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));
}
Also used : MaterializedViewMetadata(org.apache.hadoop.hive.ql.metadata.MaterializedViewMetadata) RelOptHiveTable(org.apache.hadoop.hive.ql.optimizer.calcite.RelOptHiveTable) Table(org.apache.hadoop.hive.metastore.api.Table) SourceTable(org.apache.hadoop.hive.metastore.api.SourceTable) HashMap(java.util.HashMap) SourceTable(org.apache.hadoop.hive.metastore.api.SourceTable)

Example 3 with SourceTable

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;
}
Also used : SourceTable(org.apache.hadoop.hive.metastore.api.SourceTable)

Example 4 with 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;
}
Also used : MTable(org.apache.hadoop.hive.metastore.model.MTable) MVersionTable(org.apache.hadoop.hive.metastore.model.MVersionTable) SourceTable(org.apache.hadoop.hive.metastore.api.SourceTable) Table(org.apache.hadoop.hive.metastore.api.Table) MTable(org.apache.hadoop.hive.metastore.model.MTable) SourceTable(org.apache.hadoop.hive.metastore.api.SourceTable)

Example 5 with 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);
}
Also used : Materialization(org.apache.hadoop.hive.metastore.api.Materialization) SourceTable(org.apache.hadoop.hive.metastore.api.SourceTable)

Aggregations

SourceTable (org.apache.hadoop.hive.metastore.api.SourceTable)18 Table (org.apache.hadoop.hive.metastore.api.Table)8 HashSet (java.util.HashSet)7 ArrayList (java.util.ArrayList)6 TableName (org.apache.hadoop.hive.common.TableName)4 CreationMetadata (org.apache.hadoop.hive.metastore.api.CreationMetadata)4 Table (org.apache.hadoop.hive.ql.metadata.Table)4 HashMap (java.util.HashMap)3 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)3 IOException (java.io.IOException)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 ValidTxnWriteIdList (org.apache.hadoop.hive.common.ValidTxnWriteIdList)2 TableType (org.apache.hadoop.hive.metastore.TableType)2 Warehouse (org.apache.hadoop.hive.metastore.Warehouse)2 Materialization (org.apache.hadoop.hive.metastore.api.Materialization)2 MTable (org.apache.hadoop.hive.metastore.model.MTable)2 MVersionTable (org.apache.hadoop.hive.metastore.model.MVersionTable)2