Search in sources :

Example 1 with DropConstraintMessage

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

the class DbNotificationListener method onDropConstraint.

/**
 * @param dropConstraintEvent drop constraint event
 * @throws MetaException
 */
@Override
public void onDropConstraint(DropConstraintEvent dropConstraintEvent) throws MetaException {
    String dbName = dropConstraintEvent.getDbName();
    String tableName = dropConstraintEvent.getTableName();
    String constraintName = dropConstraintEvent.getConstraintName();
    DropConstraintMessage msg = MessageBuilder.getInstance().buildDropConstraintMessage(dbName, tableName, constraintName);
    NotificationEvent event = new NotificationEvent(0, now(), EventType.DROP_CONSTRAINT.toString(), msgEncoder.getSerializer().serialize(msg));
    event.setCatName(dropConstraintEvent.getCatName());
    event.setDbName(dbName);
    event.setTableName(tableName);
    process(event, dropConstraintEvent);
}
Also used : DropConstraintMessage(org.apache.hadoop.hive.metastore.messaging.DropConstraintMessage) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent)

Example 2 with DropConstraintMessage

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

the class DropConstraintHandler method handle.

@Override
public List<Task<?>> handle(Context context) throws SemanticException {
    DropConstraintMessage msg = deserializer.getDropConstraintMessage(context.dmd.getPayload());
    final String actualDbName = context.isDbNameEmpty() ? msg.getDB() : context.dbName;
    final String actualTblName = msg.getTable();
    final TableName tName = HiveTableName.ofNullable(actualTblName, actualDbName);
    String constraintName = msg.getConstraint();
    AlterTableDropConstraintDesc dropConstraintsDesc = new AlterTableDropConstraintDesc(tName, context.eventOnlyReplicationSpec(), constraintName);
    Task<DDLWork> dropConstraintsTask = TaskFactory.get(new DDLWork(readEntitySet, writeEntitySet, dropConstraintsDesc, true, context.getDumpDirectory(), context.getMetricCollector()), context.hiveConf);
    context.log.debug("Added drop constrain task : {}:{}", dropConstraintsTask.getId(), actualTblName);
    updatedMetadata.set(context.dmd.getEventTo().toString(), actualDbName, actualTblName, null);
    return Collections.singletonList(dropConstraintsTask);
}
Also used : HiveTableName(org.apache.hadoop.hive.ql.parse.HiveTableName) TableName(org.apache.hadoop.hive.common.TableName) AlterTableDropConstraintDesc(org.apache.hadoop.hive.ql.ddl.table.constraint.drop.AlterTableDropConstraintDesc) DropConstraintMessage(org.apache.hadoop.hive.metastore.messaging.DropConstraintMessage) DDLWork(org.apache.hadoop.hive.ql.ddl.DDLWork)

Aggregations

DropConstraintMessage (org.apache.hadoop.hive.metastore.messaging.DropConstraintMessage)2 TableName (org.apache.hadoop.hive.common.TableName)1 NotificationEvent (org.apache.hadoop.hive.metastore.api.NotificationEvent)1 DDLWork (org.apache.hadoop.hive.ql.ddl.DDLWork)1 AlterTableDropConstraintDesc (org.apache.hadoop.hive.ql.ddl.table.constraint.drop.AlterTableDropConstraintDesc)1 HiveTableName (org.apache.hadoop.hive.ql.parse.HiveTableName)1