use of org.apache.atlas.typesystem.types.TraitType in project incubator-atlas by apache.
the class DataSetLineageJerseyResourceIT method setupInstances.
private void setupInstances() throws Exception {
HierarchicalTypeDefinition<TraitType> factTrait = TypesUtil.createTraitTypeDef("Fact", ImmutableSet.<String>of());
HierarchicalTypeDefinition<TraitType> etlTrait = TypesUtil.createTraitTypeDef("ETL", ImmutableSet.<String>of());
HierarchicalTypeDefinition<TraitType> dimensionTrait = TypesUtil.createTraitTypeDef("Dimension", ImmutableSet.<String>of());
HierarchicalTypeDefinition<TraitType> metricTrait = TypesUtil.createTraitTypeDef("Metric", ImmutableSet.<String>of());
createType(getTypesDef(null, null, ImmutableList.of(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 = ImmutableList.of(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 = ImmutableList.of(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", ImmutableList.of(salesFact, timeDim), ImmutableList.of(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", ImmutableList.of(salesFactDaily), ImmutableList.of(salesFactMonthly), "create table as select ", "plan", "id", "graph", "ETL");
}
use of org.apache.atlas.typesystem.types.TraitType in project incubator-atlas by apache.
the class EntityJerseyResourceIT method testUTF8.
@Test
public void testUTF8() throws Exception {
// Type names cannot be arbitrary UTF8 characters. See org.apache.atlas.type.AtlasTypeUtil#validateType()
String classType = randomString();
String attrName = random();
String attrValue = random();
HierarchicalTypeDefinition<ClassType> classTypeDefinition = TypesUtil.createClassTypeDef(classType, ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(attrName, DataTypes.STRING_TYPE));
TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(classTypeDefinition));
createType(typesDef);
Referenceable instance = new Referenceable(classType);
instance.set(attrName, attrValue);
Id guid = createInstance(instance);
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.GET_ENTITY, null, guid._getId());
Referenceable getReferenceable = InstanceSerialization.fromJsonReferenceable(response.getString(AtlasClient.DEFINITION), true);
Assert.assertEquals(getReferenceable.get(attrName), attrValue);
}
use of org.apache.atlas.typesystem.types.TraitType in project incubator-atlas by apache.
the class TypesJerseyResourceIT method createHiveTypes.
private List<HierarchicalTypeDefinition> createHiveTypes() throws Exception {
ArrayList<HierarchicalTypeDefinition> typeDefinitions = new ArrayList<>();
HierarchicalTypeDefinition<ClassType> databaseTypeDefinition = TypesUtil.createClassTypeDef("database", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef(DESCRIPTION, DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef(QUALIFIED_NAME, DataTypes.STRING_TYPE));
typeDefinitions.add(databaseTypeDefinition);
HierarchicalTypeDefinition<ClassType> tableTypeDefinition = TypesUtil.createClassTypeDef("table", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef(DESCRIPTION, DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef(QUALIFIED_NAME, DataTypes.STRING_TYPE), createOptionalAttrDef("columnNames", DataTypes.arrayTypeName(DataTypes.STRING_TYPE)), createOptionalAttrDef("created", DataTypes.DATE_TYPE), createOptionalAttrDef("parameters", DataTypes.mapTypeName(DataTypes.STRING_TYPE, DataTypes.STRING_TYPE)), TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE), new AttributeDefinition("database", "database", Multiplicity.REQUIRED, false, "database"));
typeDefinitions.add(tableTypeDefinition);
HierarchicalTypeDefinition<TraitType> fetlTypeDefinition = TypesUtil.createTraitTypeDef("fetl", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("level", DataTypes.INT_TYPE));
typeDefinitions.add(fetlTypeDefinition);
return typeDefinitions;
}
use of org.apache.atlas.typesystem.types.TraitType in project incubator-atlas by apache.
the class TypesJerseyResourceIT method testDuplicateSubmit.
@Test
public void testDuplicateSubmit() throws Exception {
HierarchicalTypeDefinition<ClassType> type = TypesUtil.createClassTypeDef(randomString(), ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE));
TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(type));
atlasClientV1.createType(typesDef);
try {
atlasClientV1.createType(typesDef);
fail("Expected 409");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.CONFLICT.getStatusCode());
}
}
use of org.apache.atlas.typesystem.types.TraitType in project incubator-atlas by apache.
the class MetadataDiscoveryJerseyResourceIT method createTypes.
private void createTypes() throws Exception {
createTypeDefinitionsV1();
HierarchicalTypeDefinition<ClassType> dslTestTypeDefinition = TypesUtil.createClassTypeDef("dsl_test_type", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE));
HierarchicalTypeDefinition<TraitType> classificationTraitDefinition = TypesUtil.createTraitTypeDef("Classification", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE));
TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.of(classificationTraitDefinition), ImmutableList.of(dslTestTypeDefinition));
createType(typesDef);
}
Aggregations