Search in sources :

Example 1 with SnapshotTable

use of bio.terra.service.snapshot.SnapshotTable in project jade-data-repo by DataBiosphere.

the class BigQueryPdao method getSnapshotTableRowCounts.

public Map<String, Long> getSnapshotTableRowCounts(Snapshot snapshot) throws InterruptedException {
    BigQueryProject bigQueryProject = bigQueryProjectForSnapshot(snapshot);
    Map<String, Long> rowCounts = new HashMap<>();
    for (SnapshotTable snapshotTable : snapshot.getTables()) {
        String tableName = snapshotTable.getName();
        String sql = new ST(rowCountTemplate).add("rowId", PDAO_ROW_ID_COLUMN).add("project", bigQueryProject.getProjectId()).add("dataset", snapshot.getName()).add("table", tableName).render();
        TableResult result = bigQueryProject.query(sql);
        rowCounts.put(tableName, getSingleLongValue(result));
    }
    return rowCounts;
}
Also used : ST(org.stringtemplate.v4.ST) TableResult(com.google.cloud.bigquery.TableResult) HashMap(java.util.HashMap) SnapshotTable(bio.terra.service.snapshot.SnapshotTable)

Aggregations

SnapshotTable (bio.terra.service.snapshot.SnapshotTable)1 TableResult (com.google.cloud.bigquery.TableResult)1 HashMap (java.util.HashMap)1 ST (org.stringtemplate.v4.ST)1