You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ni...@apache.org on 2020/10/23 14:32:38 UTC

[atlas] 05/05: ATLAS-3994 : import-hive.sh script fails when missing mandatory attribute value is null

This is an automated email from the ASF dual-hosted git repository.

nixon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 82cdd700b2133e74ca8bce9aa55d93e76c8ec6fc
Author: chaitali borole <ch...@cloudera.com>
AuthorDate: Mon Oct 19 18:08:14 2020 +0530

    ATLAS-3994 : import-hive.sh script fails when missing mandatory attribute value is null
---
 .../java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
index c0e2c1f..1bdfa4f 100755
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
@@ -91,6 +91,7 @@ public class HiveMetaStoreBridge {
 
     public static final String CONF_PREFIX                     = "atlas.hook.hive.";
     public static final String CLUSTER_NAME_KEY                = "atlas.cluster.name";
+    public static final String HIVE_USERNAME                   = "atlas.hook.hive.default.username";
     public static final String HIVE_METADATA_NAMESPACE         = "atlas.metadata.namespace";
     public static final String HDFS_PATH_CONVERT_TO_LOWER_CASE = CONF_PREFIX + "hdfs_path.convert_to_lowercase";
     public static final String HOOK_AWS_S3_ATLAS_MODEL_VERSION = CONF_PREFIX + "aws_s3.atlas.model.version";
@@ -117,7 +118,6 @@ public class HiveMetaStoreBridge {
 
     private String awsS3AtlasModelVersion = null;
 
-
     public static void main(String[] args) {
         int exitCode = EXIT_CODE_FAILED;
         AtlasClientV2 atlasClientV2 = null;
@@ -398,7 +398,11 @@ public class HiveMetaStoreBridge {
                     processInst.setAttribute(ATTRIBUTE_CLUSTER_NAME, metadataNamespace);
                     processInst.setRelationshipAttribute(ATTRIBUTE_INPUTS, Collections.singletonList(AtlasTypeUtil.getAtlasRelatedObjectId(pathInst, RELATIONSHIP_DATASET_PROCESS_INPUTS)));
                     processInst.setRelationshipAttribute(ATTRIBUTE_OUTPUTS, Collections.singletonList(AtlasTypeUtil.getAtlasRelatedObjectId(tableInst, RELATIONSHIP_PROCESS_DATASET_OUTPUTS)));
-                    processInst.setAttribute(ATTRIBUTE_USER_NAME, table.getOwner());
+                    String userName = table.getOwner();
+                    if (StringUtils.isEmpty(userName)) {
+                        userName = ApplicationProperties.get().getString(HIVE_USERNAME, "hive");
+                    }
+                    processInst.setAttribute(ATTRIBUTE_USER_NAME, userName);
                     processInst.setAttribute(ATTRIBUTE_START_TIME, now);
                     processInst.setAttribute(ATTRIBUTE_END_TIME, now);
                     processInst.setAttribute(ATTRIBUTE_OPERATION_TYPE, "CREATETABLE");