use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.
the class ImpalaLineageToolIT method testCreateTableAsSelectWithCommentSpacesFromFile.
/**
* This tests is based on extra comment and spaces adding to create table as select query
* 1) ImpalaLineageTool can parse one lineage file that contains "create table as select" command lineage,
* there is table vertex with createTime.
* 2) Lineage is sent to Atlas
* 3) Atlas can get this lineage from Atlas
*/
@Test
public void testCreateTableAsSelectWithCommentSpacesFromFile() throws Exception {
String IMPALA = dir + "impalaCreateTableAsSelectWithCommentSpaces.json";
String IMPALA_WAL = dir + "WALimpala.wal";
ImpalaLineageHook impalaLineageHook = new ImpalaLineageHook();
// create database and tables to simulate Impala behavior that Impala updates metadata
// to HMS and HMSHook sends the metadata to Atlas, which has to happen before
// Atlas can handle lineage notification
String dbName = "db_9";
createDatabase(dbName);
String sourceTableName = "table_1";
createTable(dbName, sourceTableName, "(id string, count int)", false);
String targetTableName = "table_2";
createTable(dbName, targetTableName, "(count int, id string)", false);
// process lineage record, and send corresponding notification to Atlas
String[] args = new String[] { "-d", "./", "-p", "impala" };
ImpalaLineageTool toolInstance = new ImpalaLineageTool(args);
toolInstance.importHImpalaEntities(impalaLineageHook, IMPALA, IMPALA_WAL);
// verify the process is saved in Atlas
// the value is from info in IMPALA_4.
String createTime = new Long(TABLE_CREATE_TIME * 1000).toString();
String processQFName = dbName + "." + targetTableName + AtlasImpalaHookContext.QNAME_SEP_METADATA_NAMESPACE + CLUSTER_NAME + AtlasImpalaHookContext.QNAME_SEP_PROCESS + createTime;
processQFName = processQFName.toLowerCase();
String queryString = "create /* Test */ table " + dbName + "." + targetTableName + " as /* Test */ select count, id from " + dbName + "." + sourceTableName;
AtlasEntity processEntity1 = validateProcess(processQFName, queryString);
AtlasEntity processExecutionEntity1 = validateProcessExecution(processEntity1, queryString);
AtlasObjectId process1 = toAtlasObjectId(processExecutionEntity1.getRelationshipAttribute(BaseImpalaEvent.ATTRIBUTE_PROCESS));
Assert.assertEquals(process1.getGuid(), processEntity1.getGuid());
Assert.assertEquals(numberOfProcessExecutions(processEntity1), 1);
String guid = assertTableIsRegistered(dbName, targetTableName);
AtlasEntity entity = atlasClientV2.getEntityByGuid(guid).getEntity();
List ddlQueries = (List) entity.getRelationshipAttribute(ATTRIBUTE_DDL_QUERIES);
assertNotNull(ddlQueries);
assertEquals(ddlQueries.size(), 1);
}
use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.
the class AtlasServerService method updateEntitiesWithServer.
@GraphTransaction
public void updateEntitiesWithServer(AtlasServer server, List<String> entityGuids, String attributeName) throws AtlasBaseException {
if (server != null && StringUtils.isEmpty(server.getGuid())) {
return;
}
AtlasObjectId objectId = getObjectId(server);
for (String guid : entityGuids) {
AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = entityStore.getById(guid, false, false);
updateAttribute(entityWithExtInfo, attributeName, objectId);
}
}
use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.
the class AtlasGlossaryCategoryDTO method toEntity.
@Override
public AtlasEntity toEntity(final AtlasGlossaryCategory obj) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasGlossaryCategoryDTO.toEntity()", obj);
}
Objects.requireNonNull(obj, "atlasGlossaryCategory");
Objects.requireNonNull(obj.getQualifiedName(), "atlasGlossaryCategory qualifiedName must be specified");
Objects.requireNonNull(obj.getAnchor(), "atlasGlossaryCategory anchor must be specified");
AtlasEntity ret = getDefaultAtlasEntity(obj);
ret.setAttribute("qualifiedName", obj.getQualifiedName());
ret.setAttribute("name", obj.getName());
ret.setAttribute("shortDescription", obj.getShortDescription());
ret.setAttribute("longDescription", obj.getLongDescription());
ret.setAttribute("anchor", new AtlasObjectId(obj.getAnchor().getGlossaryGuid()));
ret.setAttribute("additionalAttributes", obj.getAdditionalAttributes());
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasGlossaryCategoryDTO.toEntity() : {}", ret);
}
return ret;
}
use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.
the class StartEntityFetchByExportRequest method get.
public List<AtlasObjectId> get(AtlasExportRequest exportRequest) {
List<AtlasObjectId> list = new ArrayList<>();
for (AtlasObjectId objectId : exportRequest.getItemsToExport()) {
List<String> guids = get(exportRequest, objectId);
if (guids.isEmpty()) {
continue;
}
objectId.setGuid(guids.get(0));
list.add(objectId);
}
return list;
}
use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.
the class ExportServiceTest method getRequestForFullFetch.
private AtlasExportRequest getRequestForFullFetch() {
AtlasExportRequest request = new AtlasExportRequest();
List<AtlasObjectId> itemsToExport = new ArrayList<>();
itemsToExport.add(new AtlasObjectId("hive_db", "qualifiedName", "default@cl1"));
request.setItemsToExport(itemsToExport);
return request;
}
Aggregations