Search code examples
google-bigquerygoogle-api-java-client

Google Bigquery java client listTables return numBytes and numRows as null


When I try to find the size of all the tables using listTables API of BigQuery java client, it returns null. But if I use getTable individually, I get the proper data. Is this a known issue, or am I doing something wrong. Following is the code that returns null value for numBytes:

Page<Dataset> datasetPage = getAllDatasets("projectId");
        if(datasetPage!=null) {
            for (Dataset dataset : datasetPage.iterateAll()) {
                for(Table table : dataset.list().iterateAll()) {
                    System.out.println(table.getNumBytes());  // Returns Null. **
                }
            }
        }

Solution

  • To answer my own question listTables api is designed to return only the partial information. This is mentioned in the code document https://github.com/googleapis/java-bigquery/blob/dfa15e5ca08a3227f015a389c4c08732178a73e7/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java#L155