public List listParents()

in services/library/src/main/java/com/google/cloud/pso/bq_pii_classifier/services/scan/StandardDlpResultsScannerImpl.java [63:95]


    public List<String> listParents(String project) throws NonRetryableApplicationException, InterruptedException {

        String queryTemplate =
                "SELECT \n" +
                "DISTINCT \n" +
                "CONCAT(l.record_location.record_key.big_query_key.table_reference.project_id, '.', l.record_location.record_key.big_query_key.table_reference.dataset_id) AS dataset \n" +
                "FROM `%s.%s.%s` , UNNEST(location.content_locations) l\n" +
                "WHERE l.record_location.record_key.big_query_key.table_reference.project_id = '%s'\n";

        String formattedQuery = String.format(queryTemplate,
                hostProject,
                hostDataset,
                dlpFindingsTable,
                project
        );

        // Create a job ID so that we can safely retry.
        Job queryJob = bqService.submitJob(formattedQuery);

        TableResult result = bqService.waitAndGetJobResults(queryJob);

        List<String> projectDatasets = new ArrayList<>();
        // Construct a mapping between field names and DLP infotypes
        for (FieldValueList row : result.iterateAll()) {

            if (row.get("dataset").isNull()) {
                throw new NonRetryableApplicationException("processProjects query returned rows with null 'dataset' field.");
            }
            String datasetSpec = row.get("dataset").getStringValue();
            projectDatasets.add(datasetSpec);
        }
        return projectDatasets;
    }