Commit f9b48317 by Sarath Subramanian

ATLAS-3475: Invalid instance creation/updation parameters passed : hive_process.qualifiedName

parent b064d8c3
...@@ -24,6 +24,7 @@ import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; ...@@ -24,6 +24,7 @@ import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
import org.apache.atlas.model.notification.HookNotification; import org.apache.atlas.model.notification.HookNotification;
import org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2; import org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.hadoop.hive.metastore.TableType;
import org.apache.hadoop.hive.metastore.events.AlterTableEvent; import org.apache.hadoop.hive.metastore.events.AlterTableEvent;
import org.apache.hadoop.hive.metastore.events.CreateTableEvent; import org.apache.hadoop.hive.metastore.events.CreateTableEvent;
import org.apache.hadoop.hive.metastore.events.ListenerEvent; import org.apache.hadoop.hive.metastore.events.ListenerEvent;
...@@ -149,17 +150,15 @@ public class CreateTable extends BaseHiveEvent { ...@@ -149,17 +150,15 @@ public class CreateTable extends BaseHiveEvent {
if (context.isMetastoreHook()) { if (context.isMetastoreHook()) {
//it is running in the context of HiveMetastore //it is running in the context of HiveMetastore
//not a hive metastore hook //not a hive metastore hook
if (EXTERNAL_TABLE.equals(table.getTableType())) { if (isCreateExtTableOperation(table)) {
AtlasEntity hdfsPathEntity = getPathEntity(table.getDataLocation(), ret); if (LOG.isDebugEnabled()) {
if(LOG.isDebugEnabled()) { LOG.debug("Creating a dummy process with lineage from hdfs path to hive table");
LOG.debug("Creating a dummy process with lineage from hdfs path to table");
} }
AtlasEntity processEntity = getHiveProcessEntity(Collections.singletonList(hdfsPathEntity), AtlasEntity hdfsPathEntity = getPathEntity(table.getDataLocation(), ret);
Collections.singletonList(tblEntity)); AtlasEntity processEntity = getHiveProcessEntity(Collections.singletonList(hdfsPathEntity), Collections.singletonList(tblEntity));
ret.addEntity(processEntity); ret.addEntity(processEntity);
ret.addReferredEntity(hdfsPathEntity); ret.addReferredEntity(hdfsPathEntity);
//hive process entity will be created by hiveserver hook.
} }
} else { } else {
//not a hive metastore hook //not a hive metastore hook
...@@ -175,7 +174,6 @@ public class CreateTable extends BaseHiveEvent { ...@@ -175,7 +174,6 @@ public class CreateTable extends BaseHiveEvent {
ret.addEntity(processExecution); ret.addEntity(processExecution);
} }
} }
} }
if (!context.isMetastoreHook()) { if (!context.isMetastoreHook()) {
...@@ -197,4 +195,11 @@ public class CreateTable extends BaseHiveEvent { ...@@ -197,4 +195,11 @@ public class CreateTable extends BaseHiveEvent {
// If its an external table, even though the temp table skip flag is on, we create the table since we need the HDFS path to temp table lineage. // If its an external table, even though the temp table skip flag is on, we create the table since we need the HDFS path to temp table lineage.
return table != null && skipTempTables && table.isTemporary() && !EXTERNAL_TABLE.equals(table.getTableType()); return table != null && skipTempTables && table.isTemporary() && !EXTERNAL_TABLE.equals(table.getTableType());
} }
private boolean isCreateExtTableOperation(Table table) {
HiveOperation oper = context.getHiveOperation();
TableType tableType = table.getTableType();
return EXTERNAL_TABLE.equals(tableType) && (oper == CREATETABLE || oper == CREATETABLE_AS_SELECT);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment