From 91de0825b98bdb324bb12a74e41c4da02e1f12b0 Mon Sep 17 00:00:00 2001 From: Miguel Covarrubias Date: Fri, 23 Jun 2023 18:53:55 -0400 Subject: [PATCH] Process Sample gVCF headers during Ingest [VS-836] --- .../utils/gvs/bigquery/BigQueryUtils.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/org/broadinstitute/hellbender/utils/gvs/bigquery/BigQueryUtils.java b/src/main/java/org/broadinstitute/hellbender/utils/gvs/bigquery/BigQueryUtils.java index 1ef67d9c929..6937d00603f 100644 --- a/src/main/java/org/broadinstitute/hellbender/utils/gvs/bigquery/BigQueryUtils.java +++ b/src/main/java/org/broadinstitute/hellbender/utils/gvs/bigquery/BigQueryUtils.java @@ -451,6 +451,19 @@ public static StorageAPIAvroReaderAndBigQueryStatistics executeQueryWithStorageA } public static boolean doRowsExistFor(String projectID, String datasetName, String tableName, String columnName, String value) { + String template = "SELECT COUNT(*) FROM `%s.%s.%s` WHERE %s = '%s'"; + String query = String.format(template, projectID, datasetName, tableName, columnName, value); + + BigQueryResultAndStatistics resultAndStatistics = BigQueryUtils.executeQuery(projectID, query, true, null); + for (final FieldValueList row : resultAndStatistics.result.iterateAll()) { + final long count = row.get(0).getLongValue(); + return count != 0; + } + throw new GATKException(String.format("No rows returned from count of `%s.%s.%s` for %s = '%s'", + projectID, datasetName, tableName, columnName, value)); + } + + public static boolean doRowsExistFor(String projectID, String datasetName, String tableName, String columnName, Long value) { String template = "SELECT COUNT(*) FROM `%s.%s.%s` WHERE %s = %s"; String query = String.format(template, projectID, datasetName, tableName, columnName, value);