Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BC Break] Switch to standard SQL by default #640

Merged
merged 4 commits into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
28 changes: 18 additions & 10 deletions src/BigQuery/BigQueryClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function __construct(array $config = [])
*
* Queries constructed using
* [standard SQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/)
* can take advantage of parametriziation.
* can take advantage of parameterization.
*
* Refer to the table below for a guide on how parameter types are mapped to
* their BigQuery equivalents.
Expand Down Expand Up @@ -194,8 +194,8 @@ public function __construct(array $config = [])
* @type bool $useQueryCache Whether to look for the result in the query
* cache.
* @type bool $useLegacySql Specifies whether to use BigQuery's legacy
* SQL dialect for this query. **Defaults to** `true`. If set to
* false, the query will use
* SQL dialect for this query. **Defaults to** `false`. Unless set to

This comment was marked as spam.

* true, the query will use
* [BigQuery's standard SQL](https://cloud.google.com/bigquery/sql-reference).
* @type array $parameters Only available for standard SQL queries.
* When providing a non-associative array positional parameters
Expand All @@ -209,7 +209,8 @@ public function __construct(array $config = [])
public function runQuery($query, array $options = [])
{
$options += [
'maxRetries' => 100
'maxRetries' => 100,
'useLegacySql' => false
];

if (isset($options['parameters'])) {
Expand Down Expand Up @@ -257,7 +258,7 @@ public function runQuery($query, array $options = [])
*
* Queries constructed using
* [standard SQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/)
* can take advantage of parametriziation. For more details and examples
* can take advantage of parameterization. For more details and examples
* please see {@see Google\Cloud\BigQuery\BigQueryClient::runQuery()}.
*
* Example:
Expand Down Expand Up @@ -290,21 +291,28 @@ public function runQuery($query, array $options = [])
* named parameters will be used (`@name`).
* @type array $jobConfig Configuration settings for a query job are
* outlined in the [API Docs for `configuration.query`](https://goo.gl/PuRa3I).
* If not provided default settings will be used.
* If not provided default settings will be used, with the exception
* of `configuration.query.useLegacySql`, which defaults to `false`
* in this client.
* }
* @return Job
*/
public function runQueryAsJob($query, array $options = [])
{
if (isset($options['parameters'])) {
if (!isset($options['jobConfig'])) {
$options['jobConfig'] = [];
}
$options += [
'jobConfig' => []
];

if (isset($options['parameters'])) {
$options['jobConfig'] += $this->formatQueryParameters($options['parameters']);

unset($options['parameters']);
}

$options['jobConfig'] += [
'useLegacySql' => false
];

$config = $this->buildJobConfig(
'query',
$this->projectId,
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/BigQuery/BigQueryClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public function queryDataProvider()
[],
[
'projectId' => $this->projectId,
'query' => $query
'query' => $query,
'useLegacySql' => false
]
],
[
Expand Down