Search in sources :

Example 1 with UpdatePartitionColumnStatMessage

use of org.apache.hadoop.hive.metastore.messaging.UpdatePartitionColumnStatMessage in project hive by apache.

the class DbNotificationListener method onUpdatePartitionColumnStat.

@Override
public void onUpdatePartitionColumnStat(UpdatePartitionColumnStatEvent updatePartColStatEvent) throws MetaException {
    UpdatePartitionColumnStatMessage msg = MessageBuilder.getInstance().buildUpdatePartitionColumnStatMessage(updatePartColStatEvent.getPartColStats(), updatePartColStatEvent.getPartVals(), updatePartColStatEvent.getPartParameters(), updatePartColStatEvent.getTableObj(), updatePartColStatEvent.getWriteId());
    NotificationEvent event = new NotificationEvent(0, now(), EventType.UPDATE_PARTITION_COLUMN_STAT.toString(), msgEncoder.getSerializer().serialize(msg));
    ColumnStatisticsDesc statDesc = updatePartColStatEvent.getPartColStats().getStatsDesc();
    event.setCatName(statDesc.isSetCatName() ? statDesc.getCatName() : DEFAULT_CATALOG_NAME);
    event.setDbName(statDesc.getDbName());
    event.setTableName(statDesc.getTableName());
    process(event, updatePartColStatEvent);
}
Also used : UpdatePartitionColumnStatMessage(org.apache.hadoop.hive.metastore.messaging.UpdatePartitionColumnStatMessage) ColumnStatisticsDesc(org.apache.hadoop.hive.metastore.api.ColumnStatisticsDesc) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent)

Example 2 with UpdatePartitionColumnStatMessage

use of org.apache.hadoop.hive.metastore.messaging.UpdatePartitionColumnStatMessage in project hive by apache.

the class DbNotificationListener method onUpdatePartitionColumnStatInBatch.

@Override
public void onUpdatePartitionColumnStatInBatch(UpdatePartitionColumnStatEventBatch updatePartColStatEventBatch, Connection dbConn, SQLGenerator sqlGenerator) throws MetaException {
    List<NotificationEvent> eventBatch = new ArrayList<>();
    List<ListenerEvent> listenerEventBatch = new ArrayList<>();
    for (int i = 0; i < updatePartColStatEventBatch.getNumEntries(); i++) {
        UpdatePartitionColumnStatEvent updatePartColStatEvent = updatePartColStatEventBatch.getPartColStatEvent(i);
        UpdatePartitionColumnStatMessage msg = MessageBuilder.getInstance().buildUpdatePartitionColumnStatMessage(updatePartColStatEvent.getPartColStats(), updatePartColStatEvent.getPartVals(), updatePartColStatEvent.getPartParameters(), updatePartColStatEvent.getTableObj(), updatePartColStatEvent.getWriteId());
        ColumnStatisticsDesc statDesc = updatePartColStatEvent.getPartColStats().getStatsDesc();
        NotificationEvent event = new NotificationEvent(0, now(), EventType.UPDATE_PARTITION_COLUMN_STAT.toString(), msgEncoder.getSerializer().serialize(msg));
        event.setCatName(statDesc.isSetCatName() ? statDesc.getCatName() : DEFAULT_CATALOG_NAME);
        event.setDbName(statDesc.getDbName());
        event.setTableName(statDesc.getTableName());
        eventBatch.add(event);
        listenerEventBatch.add(updatePartColStatEvent);
    }
    try {
        addNotificationLogBatch(eventBatch, listenerEventBatch, dbConn, sqlGenerator);
    } catch (SQLException e) {
        throw new MetaException("Unable to execute direct SQL " + StringUtils.stringifyException(e));
    }
}
Also used : UpdatePartitionColumnStatMessage(org.apache.hadoop.hive.metastore.messaging.UpdatePartitionColumnStatMessage) UpdatePartitionColumnStatEvent(org.apache.hadoop.hive.metastore.events.UpdatePartitionColumnStatEvent) SQLException(java.sql.SQLException) ColumnStatisticsDesc(org.apache.hadoop.hive.metastore.api.ColumnStatisticsDesc) ArrayList(java.util.ArrayList) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent) ListenerEvent(org.apache.hadoop.hive.metastore.events.ListenerEvent) SQLUniqueConstraint(org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint) SQLCheckConstraint(org.apache.hadoop.hive.metastore.api.SQLCheckConstraint) SQLNotNullConstraint(org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint) SQLDefaultConstraint(org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Example 3 with UpdatePartitionColumnStatMessage

use of org.apache.hadoop.hive.metastore.messaging.UpdatePartitionColumnStatMessage in project hive by apache.

the class UpdatePartColStatHandler method handle.

@Override
public List<Task<?>> handle(Context context) throws SemanticException {
    UpdatePartitionColumnStatMessage upcsm = deserializer.getUpdatePartitionColumnStatMessage(context.dmd.getPayload());
    // Update tablename and database name in the statistics object
    ColumnStatistics colStats = upcsm.getColumnStatistics();
    // In older version of hive, engine might not have set.
    if (colStats.getEngine() == null) {
        colStats.setEngine(org.apache.hadoop.hive.conf.Constants.HIVE_ENGINE);
    }
    ColumnStatisticsDesc colStatsDesc = colStats.getStatsDesc();
    if (!context.isDbNameEmpty()) {
        colStatsDesc.setDbName(context.dbName);
        updatedMetadata.set(context.dmd.getEventTo().toString(), context.dbName, colStatsDesc.getTableName(), null);
    }
    try {
        return ReplUtils.addTasksForLoadingColStats(colStats, context.hiveConf, updatedMetadata, upcsm.getTableObject(), upcsm.getWriteId(), context.getDumpDirectory(), context.getMetricCollector());
    } catch (Exception e) {
        throw new SemanticException(e);
    }
}
Also used : UpdatePartitionColumnStatMessage(org.apache.hadoop.hive.metastore.messaging.UpdatePartitionColumnStatMessage) ColumnStatistics(org.apache.hadoop.hive.metastore.api.ColumnStatistics) ColumnStatisticsDesc(org.apache.hadoop.hive.metastore.api.ColumnStatisticsDesc) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException)

Aggregations

ColumnStatisticsDesc (org.apache.hadoop.hive.metastore.api.ColumnStatisticsDesc)3 UpdatePartitionColumnStatMessage (org.apache.hadoop.hive.metastore.messaging.UpdatePartitionColumnStatMessage)3 NotificationEvent (org.apache.hadoop.hive.metastore.api.NotificationEvent)2 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 ColumnStatistics (org.apache.hadoop.hive.metastore.api.ColumnStatistics)1 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)1 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)1 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)1 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)1 ListenerEvent (org.apache.hadoop.hive.metastore.events.ListenerEvent)1 UpdatePartitionColumnStatEvent (org.apache.hadoop.hive.metastore.events.UpdatePartitionColumnStatEvent)1 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)1