foxwendy
foxwendy

Reputation: 2929

Bigquery: getNumRows() returns null after tables.get?

// Retrieve the specified table resource
public Table getTable(String tableId) {
    Tables tableRequest = sBIGQUERY.tables();
    Table table = null;
    try {
        table = tableRequest.get(mProjectId, mDataset, tableId).execute();
    } catch (IOException e) {
        logger.error(e);
    }
    return table;
}

after this, in my main function:

Table info = mBigquery.getTable(tableId);
logger.info(tableId + "#" + info.getCreationTime() + "#" + info.getLastModifiedTime()+"#"+info.getNumBytes()+"#"+info.getNumRows());

sometimes info.getNumBytes() and info.getNumRows() return null but info.getCreationTime() and info.getLastModifiedTime() are just fine. Why is that?

Upvotes: 1

Views: 202

Answers (1)

Jordan Tigani
Jordan Tigani

Reputation: 26617

BigQuery will not return the number of rows in a table if the number of rows is not known ahead of time. The primary way this happens is with tables that have been written to recently via streaming operations (tabledata.insertall()). It can also happen with certain types of tables that are links to Google internal data (this is rare), or with table views, where the number of rows is not computed when the underlying tables change.

Upvotes: 1

Related Questions