Search in sources :

Example 1 with ImportException

use of org.apache.sqoop.util.ImportException in project atlas by apache.

the class SqoopHook method toSqoopDBStoreEntity.

private AtlasEntity toSqoopDBStoreEntity(SqoopJobDataPublisher.Data data) throws ImportException {
    String table = data.getStoreTable();
    String query = data.getStoreQuery();
    if (StringUtils.isBlank(table) && StringUtils.isBlank(query)) {
        throw new ImportException("Both table and query cannot be empty for DBStoreInstance");
    }
    String usage = table != null ? "TABLE" : "QUERY";
    String source = table != null ? table : query;
    String name = getSqoopDBStoreName(data);
    AtlasEntity entDbStore = new AtlasEntity(SqoopDataTypes.SQOOP_DBDATASTORE.getName());
    entDbStore.setAttribute(AtlasClient.NAME, name);
    entDbStore.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
    entDbStore.setAttribute(SqoopHook.DB_STORE_TYPE, data.getStoreType());
    entDbStore.setAttribute(SqoopHook.DB_STORE_USAGE, usage);
    entDbStore.setAttribute(SqoopHook.STORE_URI, data.getUrl());
    entDbStore.setAttribute(SqoopHook.SOURCE, source);
    entDbStore.setAttribute(SqoopHook.DESCRIPTION, "");
    entDbStore.setAttribute(AtlasClient.OWNER, data.getUser());
    return entDbStore;
}
Also used : ImportException(org.apache.sqoop.util.ImportException) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity)

Example 2 with ImportException

use of org.apache.sqoop.util.ImportException in project incubator-atlas by apache.

the class SqoopHook method createDBStoreInstance.

private Referenceable createDBStoreInstance(SqoopJobDataPublisher.Data data) throws ImportException {
    Referenceable storeRef = new Referenceable(SqoopDataTypes.SQOOP_DBDATASTORE.getName());
    String table = data.getStoreTable();
    String query = data.getStoreQuery();
    if (StringUtils.isBlank(table) && StringUtils.isBlank(query)) {
        throw new ImportException("Both table and query cannot be empty for DBStoreInstance");
    }
    String usage = table != null ? "TABLE" : "QUERY";
    String source = table != null ? table : query;
    String name = getSqoopDBStoreName(data);
    storeRef.set(AtlasClient.NAME, name);
    storeRef.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
    storeRef.set(SqoopHook.DB_STORE_TYPE, data.getStoreType());
    storeRef.set(SqoopHook.DB_STORE_USAGE, usage);
    storeRef.set(SqoopHook.STORE_URI, data.getUrl());
    storeRef.set(SqoopHook.SOURCE, source);
    storeRef.set(SqoopHook.DESCRIPTION, "");
    storeRef.set(AtlasClient.OWNER, data.getUser());
    return storeRef;
}
Also used : ImportException(org.apache.sqoop.util.ImportException) Referenceable(org.apache.atlas.typesystem.Referenceable)

Aggregations

ImportException (org.apache.sqoop.util.ImportException)2 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)1 Referenceable (org.apache.atlas.typesystem.Referenceable)1