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 2019/05/24 12:30:15 UTC
[atlas] 01/02: ATLAS-3202: Hive hook: getStorageDescEntity() throws
NPE if bucketCols is null
This is an automated email from the ASF dual-hosted git repository.
nixon pushed a commit to branch branch-1.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
commit fd3f1777ec687ae21596c526690cb723fda9b4ff
Author: Sarath Subramanian <sa...@apache.org>
AuthorDate: Sat May 11 16:21:38 2019 -0700
ATLAS-3202: Hive hook: getStorageDescEntity() throws NPE if bucketCols is null
---
.../atlas/hive/hook/events/BaseHiveEvent.java | 54 +++++++++++-----------
1 file changed, 28 insertions(+), 26 deletions(-)
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
index b6754f7..0365e7c 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
@@ -463,7 +463,7 @@ public abstract class BaseHiveEvent {
ret.setAttribute(ATTRIBUTE_NUM_BUCKETS, sd.getNumBuckets());
ret.setAttribute(ATTRIBUTE_STORED_AS_SUB_DIRECTORIES, sd.isStoredAsSubDirectories());
- if (sd.getBucketCols().size() > 0) {
+ if (sd.getBucketCols() != null && sd.getBucketCols().size() > 0) {
ret.setAttribute(ATTRIBUTE_BUCKET_COLS, sd.getBucketCols());
}
@@ -500,36 +500,38 @@ public abstract class BaseHiveEvent {
}
protected List<AtlasEntity> getColumnEntities(AtlasObjectId tableId, Table table, List<FieldSchema> fieldSchemas) {
- List<AtlasEntity> ret = new ArrayList<>();
- boolean isKnownTable = tableId.getGuid() == null;
-
- int columnPosition = 0;
- for (FieldSchema fieldSchema : fieldSchemas) {
- String colQualifiedName = getQualifiedName(table, fieldSchema);
- AtlasEntity column = context.getEntity(colQualifiedName);
+ List<AtlasEntity> ret = new ArrayList<>();
+ boolean isKnownTable = tableId.getGuid() == null;
+ int columnPosition = 0;
+
+ if (CollectionUtils.isNotEmpty(fieldSchemas)) {
+ for (FieldSchema fieldSchema : fieldSchemas) {
+ String colQualifiedName = getQualifiedName(table, fieldSchema);
+ AtlasEntity column = context.getEntity(colQualifiedName);
+
+ if (column == null) {
+ column = new AtlasEntity(HIVE_TYPE_COLUMN);
+
+ // if column's table was sent in an earlier notification, set 'guid' to null - which will:
+ // - result in this entity to be not included in 'referredEntities'
+ // - cause Atlas server to resolve the entity by its qualifiedName
+ if (isKnownTable) {
+ column.setGuid(null);
+ }
- if (column == null) {
- column = new AtlasEntity(HIVE_TYPE_COLUMN);
+ column.setAttribute(ATTRIBUTE_TABLE, tableId);
+ column.setAttribute(ATTRIBUTE_QUALIFIED_NAME, colQualifiedName);
+ column.setAttribute(ATTRIBUTE_NAME, fieldSchema.getName());
+ column.setAttribute(ATTRIBUTE_OWNER, table.getOwner());
+ column.setAttribute(ATTRIBUTE_COL_TYPE, fieldSchema.getType());
+ column.setAttribute(ATTRIBUTE_COL_POSITION, columnPosition++);
+ column.setAttribute(ATTRIBUTE_COMMENT, fieldSchema.getComment());
- // if column's table was sent in an earlier notification, set 'guid' to null - which will:
- // - result in this entity to be not included in 'referredEntities'
- // - cause Atlas server to resolve the entity by its qualifiedName
- if (isKnownTable) {
- column.setGuid(null);
+ context.putEntity(colQualifiedName, column);
}
- column.setAttribute(ATTRIBUTE_TABLE, tableId);
- column.setAttribute(ATTRIBUTE_QUALIFIED_NAME, colQualifiedName);
- column.setAttribute(ATTRIBUTE_NAME, fieldSchema.getName());
- column.setAttribute(ATTRIBUTE_OWNER, table.getOwner());
- column.setAttribute(ATTRIBUTE_COL_TYPE, fieldSchema.getType());
- column.setAttribute(ATTRIBUTE_COL_POSITION, columnPosition++);
- column.setAttribute(ATTRIBUTE_COMMENT, fieldSchema.getComment());
-
- context.putEntity(colQualifiedName, column);
+ ret.add(column);
}
-
- ret.add(column);
}
return ret;