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

feat(Bigquery): Undelete table sample. #1774

Merged
merged 10 commits into from
Feb 20, 2023

Conversation

yash30201
Copy link
Contributor

@yash30201 yash30201 commented Feb 7, 2023

This sample showcases how to restore an accidently deleted table within the time travel window.

@yash30201 yash30201 added api: bigquery Issues related to the BigQuery API. samples Issues that are directly related to samples. labels Feb 7, 2023
@yash30201 yash30201 requested a review from a team as a code owner February 7, 2023 15:53
@snippet-bot
Copy link

snippet-bot bot commented Feb 7, 2023

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@vishwarajanand
Copy link
Member

A side comment, do you think adding a break after foundValue is set in verifyTable makes sense?

foreach ($table->rows([]) as $row) {
foreach ($row as $column => $value) {
if ($value == $expectedValue) {
$foundValue = true;
}
}
$numRows++;
}

@vishwarajanand
Copy link
Member

LGTM, just fix the few remaining nits and we are good to go.

@yash30201 yash30201 changed the title feat(Bigquery): Snapshot restore sample. feat(Bigquery): Undelete table sample. Feb 15, 2023
@yash30201
Copy link
Contributor Author

A side comment, do you think adding a break after foundValue is set in verifyTable makes sense?

foreach ($table->rows([]) as $row) {
foreach ($row as $column => $value) {
if ($value == $expectedValue) {
$foundValue = true;
}
}
$numRows++;
}

@vishwarajanand, As we need to get the numRows also, so breaking would give incorrent numRows value thus the assertion would fail. Thus putting a break isn't feasible there.

@vishwarajanand
Copy link
Member

@yash30201 I was suggesting something like below which would preserve the $numRows value:

 foreach ($table->rows([]) as $row) { 
     foreach ($row as $column => $value) { 
         if ($value == $expectedValue) { 
             $foundValue = true;  
             break;  // here
         } 
     } 
     $numRows++; 
 } 

@yash30201
Copy link
Contributor Author

yash30201 commented Feb 16, 2023

@yash30201 I was suggesting something like below which would preserve the $numRows value:

 foreach ($table->rows([]) as $row) { 
     foreach ($row as $column => $value) { 
         if ($value == $expectedValue) { 
             $foundValue = true;  
             break;  // here
         } 
     } 
     $numRows++; 
 } 

@vishwarajanand , Oh you meant breaking just the inner loop, then should we do as follows?

 foreach ($table->rows([]) as $row) { 
     if (!$foundValue) {
         foreach ($row as $column => $value) { 
             if ($value == $expectedValue) { 
                 $foundValue = true;  
                 break;  // here
             } 
         }
     } 
     $numRows++; 
 }

Because apart from matching row, all other rows would be traversed completely in your code suggestion and thus putting a single break won't make much performance difference.

Copy link
Member

@vishwarajanand vishwarajanand left a comment

Choose a reason for hiding this comment

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

LGTM

@vishwarajanand vishwarajanand merged commit 4eb5c62 into GoogleCloudPlatform:main Feb 20, 2023
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. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants