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

Adds an option to return raw results from BigQuery #1872

Merged
merged 2 commits into from
May 29, 2019

Conversation

danielgsims
Copy link
Contributor

See #1287

@danielgsims danielgsims requested a review from dwsupplee as a code owner May 5, 2019 22:01
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 5, 2019
@danielgsims danielgsims requested a review from jdpedrie May 5, 2019 22:01
@danielgsims danielgsims added the api: bigquery Issues related to the BigQuery API. label May 5, 2019
@codecov
Copy link

codecov bot commented May 5, 2019

Codecov Report

Merging #1872 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1872      +/-   ##
============================================
+ Coverage     91.59%   91.65%   +0.05%     
- Complexity     4412     4421       +9     
============================================
  Files           305      305              
  Lines         13100    13110      +10     
============================================
+ Hits          11999    12016      +17     
+ Misses         1101     1094       -7
Impacted Files Coverage Δ Complexity Δ
BigQuery/src/BigQueryClient.php 95.96% <ø> (ø) 24 <0> (ø) ⬇️
BigQuery/src/QueryResults.php 95.16% <100%> (+0.24%) 22 <5> (+3) ⬆️
Firestore/src/Query.php 99.19% <0%> (-0.81%) 85% <0%> (+11%)
Debugger/src/Agent.php 0% <0%> (ø) 27% <0%> (ø) ⬇️
Firestore/src/FieldPath.php 100% <0%> (ø) 21% <0%> (+1%) ⬆️
Firestore/src/FirestoreClient.php 100% <0%> (ø) 20% <0%> (+2%) ⬆️
Datastore/src/Connection/Grpc.php 98.08% <0%> (+0.02%) 48% <0%> (+1%) ⬆️
Firestore/src/SnapshotTrait.php 100% <0%> (+3.84%) 26% <0%> (-2%) ⬇️
Firestore/src/Connection/Grpc.php 100% <0%> (+6.17%) 12% <0%> (-7%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff5030f...918bc11. Read the comment docs.

@@ -146,6 +146,9 @@ public function __construct(
* **Defaults to** `10000` milliseconds (10 seconds).
* @type int $maxRetries The number of times to poll the Job status,
* until the job is complete. By default, will poll indefinitely.
* @type bool $returnRawResults Returns the raw data types returned from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A common way to execute queries is through BigQueryClient::runQuery which does a little magic to hide the interaction with the QueryResults class. Could we please make sure to also surface configuration option there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Dave. I started looking into this and was hoping you could help me come with an example? In the snippet below I used the runQuery command, get a result set back, and then pass the returnRawResults option while retrieving rows.

$queryJobConfig = $bigQuery->query($query);
$queryResults = $bigQuery->runQuery($queryJobConfig);

$rows = $queryResults->rows(['returnRawResults' => true]);
foreach ($rows as $row) {
   print_r($row);
}

Does this look like what you had in mind?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Close, I was thinking like this:

$queryResults = $bigQuery->runQuery($queryJobConfig, [
    'returnRawResults' => true // make sure this is surfaced in the `runQuery` documentation
]);

foreach ($queryResults as $row) {
    // ....
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dwsupplee - The option is being passed via the runQuery result now 👍

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label May 12, 2019
@dwsupplee dwsupplee added needs work This is a pull request that needs a little love. and removed 🚨 This issue needs some love. labels May 16, 2019
@danielgsims danielgsims removed the needs work This is a pull request that needs a little love. label May 23, 2019
@dwsupplee dwsupplee merged commit ed835ec into googleapis:master May 29, 2019
@jdpedrie jdpedrie mentioned this pull request Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants