use of bio.terra.service.snapshot.SnapshotMapColumn in project jade-data-repo by DataBiosphere.
the class BigQueryPdao method sourceSelectSql.
private String sourceSelectSql(String snapshotId, Column targetColumn, SnapshotMapTable mapTable) {
// In the future, there may not be a column map for a given target column; it might not exist
// in the table. The logic here covers these cases:
// 1) no source column: supply NULL
// 2) source is simple datatype FILEREF or DIRREF:
// generate the expression to construct the DRS URI: supply AS target name
// 3) source is a repeating FILEREF or DIRREF:
// generate the unnest/re-nest to construct array of DRS URI: supply AS target name
// 4) source and target column with same name, just list source name
// 5) If source and target column with different names: supply AS target name
String targetColumnName = targetColumn.getName();
SnapshotMapColumn mapColumn = lookupMapColumn(targetColumn, mapTable);
if (mapColumn == null) {
return "NULL AS " + targetColumnName;
} else {
String colType = mapColumn.getFromColumn().getType();
String mapName = mapColumn.getFromColumn().getName();
if (StringUtils.equalsIgnoreCase(colType, "FILEREF") || StringUtils.equalsIgnoreCase(colType, "DIRREF")) {
String drsPrefix = "'drs://" + datarepoDnsName + "/v1_" + snapshotId + "_'";
if (targetColumn.isArrayOf()) {
return "ARRAY(SELECT CONCAT(" + drsPrefix + ", x) " + "FROM UNNEST(" + mapName + ") AS x) AS " + targetColumnName;
} else {
return "CONCAT(" + drsPrefix + ", " + mapName + ") AS " + targetColumnName;
}
} else if (StringUtils.equalsIgnoreCase(mapName, targetColumnName)) {
return targetColumnName;
} else {
return mapName + " AS " + targetColumnName;
}
}
}
use of bio.terra.service.snapshot.SnapshotMapColumn in project jade-data-repo by DataBiosphere.
the class CreateSnapshotFireStoreDataStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
// We need a complete snapshot; use the snapshotService to get one.
Snapshot snapshot = snapshotService.retrieveByName(snapshotReq.getName());
// bounds the intermediate size in a way.
for (SnapshotSource snapshotSource : snapshot.getSnapshotSources()) {
for (SnapshotMapTable mapTable : snapshotSource.getSnapshotMapTables()) {
for (SnapshotMapColumn mapColumn : mapTable.getSnapshotMapColumns()) {
String fromDatatype = mapColumn.getFromColumn().getType();
if (StringUtils.equalsIgnoreCase(fromDatatype, "FILEREF") || StringUtils.equalsIgnoreCase(fromDatatype, "DIRREF")) {
List<String> refIds = bigQueryPdao.getSnapshotRefIds(snapshotSource.getDataset(), snapshot.getName(), mapTable.getFromTable().getName(), mapTable.getFromTable().getId().toString(), mapColumn.getFromColumn());
Dataset dataset = datasetService.retrieve(snapshotSource.getDataset().getId());
fileDao.addFilesToSnapshot(dataset, snapshot, refIds);
dependencyDao.storeSnapshotFileDependencies(dataset, snapshot.getId().toString(), refIds);
}
}
}
}
return StepResult.getStepResultSuccess();
}
Aggregations