Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions BigQuery/src/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class Table
{
const MAX_RETRIES = 100;
const INSERT_CREATE_MAX_DELAY_MICROSECONDS = 60000000;
public const BASIC_METADATA_VIEW = 'BASIC';
public const FULL_METADATA_VIEW = 'FULL';
public const STORAGE_STATS_METADATA_VIEW = 'STORAGE_STATS';
public const UNSPECIFIED_METADATA_VIEW = 'TABLE_METADATA_VIEW_UNSPECIFIED';

use ArrayTrait;
use ConcurrencyControlTrait;
Expand Down Expand Up @@ -717,7 +721,15 @@ public function insertRows(array $rows, array $options = [])
*
* @see https://cloud.google.com/bigquery/docs/reference/rest/v2/tables Tables resource documentation.
*
* @param array $options [optional] Configuration options.
* @param array $options [optional] {
* Configuration options.
*
* **Note:** If metadata is already cached, $options will be ignored.
* Use {@see Table::reload()} to force a refresh with specific options.
*
* More information:
* https://docs.cloud.google.com/bigquery/docs/reference/rest/v2/tables/get#query-parameters
* }
* @return array
*/
public function info(array $options = [])
Expand All @@ -741,7 +753,12 @@ public function info(array $options = [])
*
* @see https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/get Tables get API documentation.
*
* @param array $options [optional] Configuration options.
* @param array $options [optional] {
* Configuration options.
*
* More information:
* https://docs.cloud.google.com/bigquery/docs/reference/rest/v2/tables/get#query-parameters
* }
* @return array
*/
public function reload(array $options = [])
Expand Down
29 changes: 29 additions & 0 deletions BigQuery/tests/System/ManageTablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,33 @@ public function referenceFileSchemaTestUris()
],
];
}

public function testTableView()
{
$id = uniqid(self::TESTING_PREFIX);
$table = self::$dataset->createTable($id, [
'schema' => [
'fields' => [
['name' => 'column', 'type' => 'STRING']
]
]
]);

$this->runJob($table->load('{"column": "test"}' . PHP_EOL, [
'configuration' => [
'load' => [
'sourceFormat' => 'NEWLINE_DELIMITED_JSON'
]
]
]));

// BASIC view should not include storage statistics
$info = $table->reload(['view' => Table::BASIC_METADATA_VIEW]);
$this->assertArrayNotHasKey('numRows', $info);

// FULL view should include storage statistics
$info = $table->reload(['view' => Table::FULL_METADATA_VIEW]);
$this->assertArrayHasKey('numRows', $info);
$this->assertEquals(1, $info['numRows']);
}
}
Loading