Search in sources :

Example 96 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class BaseResourceIT method createHiveDBInstanceBuiltIn.

protected Referenceable createHiveDBInstanceBuiltIn(String dbName) {
    Referenceable databaseInstance = new Referenceable(DATABASE_TYPE_BUILTIN);
    databaseInstance.set(NAME, dbName);
    databaseInstance.set(QUALIFIED_NAME, dbName);
    databaseInstance.set(CLUSTER_NAME, randomString());
    databaseInstance.set(DESCRIPTION, "foo database");
    return databaseInstance;
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable)

Example 97 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class BaseResourceIT method createHiveTableInstanceBuiltIn.

protected Referenceable createHiveTableInstanceBuiltIn(String dbName, String tableName, Id dbId) throws Exception {
    Map<String, Object> values = new HashMap<>();
    values.put(NAME, dbName);
    values.put(DESCRIPTION, "foo database");
    values.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, dbName);
    values.put("owner", "user1");
    values.put(CLUSTER_NAME, "cl1");
    values.put("parameters", Collections.EMPTY_MAP);
    values.put("location", "/tmp");
    Referenceable databaseInstance = new Referenceable(dbId._getId(), dbId.getTypeName(), values);
    Referenceable tableInstance = new Referenceable(HIVE_TABLE_TYPE_BUILTIN, CLASSIFICATION, PII_TAG, PHI_TAG, PCI_TAG, SOX_TAG, SEC_TAG, FINANCE_TAG);
    tableInstance.set(NAME, tableName);
    tableInstance.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
    tableInstance.set("db", databaseInstance);
    tableInstance.set(DESCRIPTION, "bar table");
    tableInstance.set("lastAccessTime", "2014-07-11T08:00:00.000Z");
    tableInstance.set("type", "managed");
    tableInstance.set("level", 2);
    // enum
    tableInstance.set("tableType", 1);
    tableInstance.set("compressed", false);
    Struct traitInstance = (Struct) tableInstance.getTrait("classification");
    traitInstance.set("tag", "foundation_etl");
    Struct serde1Instance = new Struct("serdeType");
    serde1Instance.set(NAME, "serde1");
    serde1Instance.set("serde", "serde1");
    tableInstance.set("serde1", serde1Instance);
    Struct serde2Instance = new Struct("serdeType");
    serde2Instance.set(NAME, "serde2");
    serde2Instance.set("serde", "serde2");
    tableInstance.set("serde2", serde2Instance);
    List<String> traits = tableInstance.getTraitNames();
    Assert.assertEquals(traits.size(), 7);
    return tableInstance;
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) HashMap(java.util.HashMap) AtlasStruct(org.apache.atlas.model.instance.AtlasStruct) Struct(org.apache.atlas.v1.model.instance.Struct)

Example 98 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class DataSetLineageJerseyResourceIT method setupInstances.

private void setupInstances() throws Exception {
    TraitTypeDefinition factTrait = TypesUtil.createTraitTypeDef(FACT, null, Collections.<String>emptySet());
    TraitTypeDefinition etlTrait = TypesUtil.createTraitTypeDef(ETL, null, Collections.<String>emptySet());
    TraitTypeDefinition dimensionTrait = TypesUtil.createTraitTypeDef(DIMENSION, null, Collections.<String>emptySet());
    TraitTypeDefinition metricTrait = TypesUtil.createTraitTypeDef(METRIC, null, Collections.<String>emptySet());
    createType(getTypesDef(null, null, Arrays.asList(factTrait, etlTrait, dimensionTrait, metricTrait), null));
    salesDBName = "Sales" + randomString();
    Id salesDB = database(salesDBName, "Sales Database", "John ETL", "hdfs://host:8000/apps/warehouse/sales");
    List<Referenceable> salesFactColumns = Arrays.asList(column("time_id", "int", "time id"), column("product_id", "int", "product id"), column("customer_id", "int", "customer id", PII), column("sales", "double", "product id", METRIC));
    salesFactTable = "sales_fact" + randomString();
    Id salesFact = table(salesFactTable, "sales fact table", salesDB, "Joe", "MANAGED", salesFactColumns, FACT);
    List<Referenceable> timeDimColumns = Arrays.asList(column("time_id", "int", "time id"), column("dayOfYear", "int", "day Of Year"), column("weekDay", "int", "week Day"));
    Id timeDim = table("time_dim" + randomString(), "time dimension table", salesDB, "John Doe", "EXTERNAL", timeDimColumns, DIMENSION);
    Id reportingDB = database("Reporting" + randomString(), "reporting database", "Jane BI", "hdfs://host:8000/apps/warehouse/reporting");
    Id salesFactDaily = table("sales_fact_daily_mv" + randomString(), "sales fact daily materialized view", reportingDB, "Joe BI", "MANAGED", salesFactColumns, METRIC);
    loadProcess("loadSalesDaily" + randomString(), "John ETL", Arrays.asList(salesFact, timeDim), Collections.singletonList(salesFactDaily), "create table as select ", "plan", "id", "graph", ETL);
    salesMonthlyTable = "sales_fact_monthly_mv" + randomString();
    Id salesFactMonthly = table(salesMonthlyTable, "sales fact monthly materialized view", reportingDB, "Jane BI", "MANAGED", salesFactColumns, METRIC);
    loadProcess("loadSalesMonthly" + randomString(), "John ETL", Collections.singletonList(salesFactDaily), Collections.singletonList(salesFactMonthly), "create table as select ", "plan", "id", "graph", ETL);
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) TraitTypeDefinition(org.apache.atlas.v1.model.typedef.TraitTypeDefinition) Id(org.apache.atlas.v1.model.instance.Id)

Example 99 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class DataSetLineageJerseyResourceIT method table.

Id table(String name, String description, Id dbId, String owner, String tableType, List<Referenceable> columns, String... traitNames) throws Exception {
    Referenceable referenceable = new Referenceable(HIVE_TABLE_TYPE, traitNames);
    referenceable.set("name", name);
    referenceable.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
    referenceable.set("description", description);
    referenceable.set("owner", owner);
    referenceable.set("tableType", tableType);
    referenceable.set("createTime", System.currentTimeMillis());
    referenceable.set("lastAccessTime", System.currentTimeMillis());
    referenceable.set("retention", System.currentTimeMillis());
    referenceable.set("db", dbId);
    referenceable.set("columns", columns);
    return createInstance(referenceable);
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable)

Example 100 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class DataSetLineageJerseyResourceIT method loadProcess.

Id loadProcess(String name, String user, List<Id> inputTables, List<Id> outputTables, String queryText, String queryPlan, String queryId, String queryGraph, String... traitNames) throws Exception {
    Referenceable referenceable = new Referenceable(HIVE_PROCESS_TYPE, traitNames);
    referenceable.set("name", name);
    referenceable.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
    referenceable.set("userName", user);
    referenceable.set("startTime", System.currentTimeMillis());
    referenceable.set("endTime", System.currentTimeMillis() + 10000);
    referenceable.set("inputs", inputTables);
    referenceable.set("outputs", outputTables);
    referenceable.set("operationType", "testOperation");
    referenceable.set("queryText", queryText);
    referenceable.set("queryPlan", queryPlan);
    referenceable.set("queryId", queryId);
    referenceable.set("queryGraph", queryGraph);
    return createInstance(referenceable);
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable)

Aggregations

Referenceable (org.apache.atlas.v1.model.instance.Referenceable)143 Test (org.testng.annotations.Test)64 Id (org.apache.atlas.v1.model.instance.Id)37 Struct (org.apache.atlas.v1.model.instance.Struct)23 ArrayList (java.util.ArrayList)20 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)15 HashMap (java.util.HashMap)12 List (java.util.List)10 AtlasException (org.apache.atlas.AtlasException)10 HookNotification (org.apache.atlas.model.notification.HookNotification)10 Map (java.util.Map)9 EntityUpdateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest)9 AtlasServiceException (org.apache.atlas.AtlasServiceException)8 EntityAuditEvent (org.apache.atlas.EntityAuditEvent)8 EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)7 EntityCreateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest)7 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)6 EntityResult (org.apache.atlas.model.legacy.EntityResult)6 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)6 EntityNotificationTest (org.apache.atlas.notification.entity.EntityNotificationTest)5