Commit 6f241db4 by Suma Shivaprasad

ATLAS-877 CreateTime of an entity(for example hive table) changes for every update (sumasai)

parent 9d1040b7
......@@ -44,7 +44,6 @@ import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hadoop.hive.metastore.api.Order;
import org.apache.hadoop.hive.metastore.api.SerDeInfo;
import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
import org.apache.hadoop.hive.ql.metadata.Hive;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.metadata.Table;
......@@ -73,7 +72,7 @@ public class HiveMetaStoreBridge {
public static final String TEMP_TABLE_PREFIX = "_temp-";
private final String clusterName;
public static final int MILLIS_CONVERT_FACTOR = 1000;
public static final long MILLIS_CONVERT_FACTOR = 1000;
public static final String ATLAS_ENDPOINT = "atlas.rest.address";
......@@ -403,9 +402,10 @@ public class HiveMetaStoreBridge {
tableReference.set(HiveDataModelGenerator.OWNER, hiveTable.getOwner());
Date createDate = new Date();
if (hiveTable.getMetadata().getProperty(hive_metastoreConstants.DDL_TIME) != null){
if (hiveTable.getTTable() != null){
try {
createDate = new Date(Long.parseLong(hiveTable.getMetadata().getProperty(hive_metastoreConstants.DDL_TIME)) * MILLIS_CONVERT_FACTOR);
createDate = new Date(hiveTable.getTTable().getCreateTime() * MILLIS_CONVERT_FACTOR);
LOG.debug("Setting create time to {} ", createDate);
tableReference.set(HiveDataModelGenerator.CREATE_TIME, createDate);
} catch(NumberFormatException ne) {
LOG.error("Error while updating createTime for the table {} ", hiveTable.getCompleteName(), ne);
......
......@@ -711,7 +711,11 @@ public class HiveHookIT {
String tableName = createTable(true);
final String newDBName = createDatabase();
assertTableIsRegistered(DEFAULT_DB, tableName);
String tableId = assertTableIsRegistered(DEFAULT_DB, tableName);
Referenceable tableEntity = atlasClient.getEntity(tableId);
final String createTime = (String)tableEntity.get(HiveDataModelGenerator.CREATE_TIME);
Assert.assertNotNull(createTime);
String columnGuid = assertColumnIsRegistered(HiveMetaStoreBridge.getColumnQualifiedName(HiveMetaStoreBridge.getTableQualifiedName(CLUSTER_NAME, DEFAULT_DB, tableName), NAME));
String sdGuid = assertSDIsRegistered(HiveMetaStoreBridge.getStorageDescQFName(HiveMetaStoreBridge.getTableQualifiedName(CLUSTER_NAME, DEFAULT_DB, tableName)), null);
assertDatabaseIsRegistered(newDBName);
......@@ -728,7 +732,7 @@ public class HiveHookIT {
final String newTableName = tableName();
String query = String.format("alter table %s rename to %s", DEFAULT_DB + "." + tableName, newDBName + "." + newTableName);
runCommand(query);
runCommandWithDelay(query, 1000);
String newColGuid = assertColumnIsRegistered(HiveMetaStoreBridge.getColumnQualifiedName(HiveMetaStoreBridge.getTableQualifiedName(CLUSTER_NAME, newDBName, newTableName), NAME));
Assert.assertEquals(newColGuid, columnGuid);
......@@ -750,6 +754,7 @@ public class HiveHookIT {
Referenceable sd = ((Referenceable) entity.get(HiveDataModelGenerator.STORAGE_DESC));
String location = (String) sd.get(HiveDataModelGenerator.LOCATION);
assertTrue(location.contains(newTableName));
Assert.assertEquals(entity.get(HiveDataModelGenerator.CREATE_TIME), createTime);
}
});
}
......
......@@ -24,6 +24,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset
ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags)
ALL CHANGES:
ATLAS-877 CreateTime of an entity(for example hive table) changes for every update (sumasai)
ATLAS-642 import-hive should create the lineage for external tables (svimal2106 via sumasai)
ATLAS-901 Log messages that cannot be sent to Kafka to a specific log configuration (yhemanth)
ATLAS-911 Get entity by unique attribute doesn't enforce type (shwethags)
......
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