datahub.spark.model.dataset.JdbcDataset Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datahub-spark-lineage Show documentation
Show all versions of datahub-spark-lineage Show documentation
Library to push data lineage from spark to datahub
package datahub.spark.model.dataset;
import com.linkedin.common.FabricType;
import io.opentracing.contrib.jdbc.parser.URLParser;
import java.util.HashMap;
import java.util.Map;
import lombok.ToString;
@ToString
public class JdbcDataset extends SparkDataset {
// TODO: Should map to the central location on datahub for platform names
private static final Map PLATFORM_NAME_MAPPING = new HashMap<>();
static {
PLATFORM_NAME_MAPPING.put("postgresql", "postgres");
}
public JdbcDataset(String url, String tbl, String platformInstance, FabricType fabricType) {
super(platformName(url), platformInstance, dsName(url, tbl), fabricType);
}
private static String platformName(String url) {
String dbType = URLParser.parse(url).getDbType();
return PLATFORM_NAME_MAPPING.getOrDefault(dbType, dbType);
}
private static String dsName(String url, String tbl) {
return URLParser.parse(url).getDbInstance() + "." + tbl;
}
}