Skip to content

feat(BigQuery): Add reservation and jobTimeoutMs setters to JobConfigurationTrait#8685

Merged
cy-yun merged 1 commit intogoogleapis:mainfrom
cy-yun:reservation
Nov 4, 2025
Merged

feat(BigQuery): Add reservation and jobTimeoutMs setters to JobConfigurationTrait#8685
cy-yun merged 1 commit intogoogleapis:mainfrom
cy-yun:reservation

Conversation

@cy-yun
Copy link
Copy Markdown
Contributor

@cy-yun cy-yun commented Oct 23, 2025

@cy-yun cy-yun requested review from a team October 23, 2025 00:44
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the BigQuery API. label Oct 23, 2025
Comment thread BigQuery/src/JobConfigurationTrait.php Outdated
* @param string $reservation The reservation to use.
* @return JobConfigurationInterface
*/
public function reservation(string $reservation)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's add the return type here:

public function reservation(string $reservation): JobConfigurationInterface

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When I add the return type and run the Unit tests I wrote, I get this failure

TypeError : Trait6e3f66f4623bd9942662da0d3da3875dc1f84673::jobTimeoutMs(): Return value must be of type Google\Cloud\BigQuery\JobConfigurationInterface, Trait6e3f66f4623bd9942662da0d3da3875dc1f84673 returned

So I omitted the return type. Let me know if you have any suggestions.

Copy link
Copy Markdown
Contributor

@bshaffer bshaffer Oct 30, 2025

Choose a reason for hiding this comment

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

This is because you're not returning JobConfigurationInterface, you're returning an instance of TestHelpers::impl(JobConfigurationTrait::class), which is mocking a trait class (e.g. Trait12345...).

So you need to either write the test in a way that actually returns a JobConfigurationInterface, or you need to change the return type to be something like self instead...

Comment thread BigQuery/src/JobConfigurationTrait.php Outdated
* @param int $jobTimeoutMs The job timeout in milliseconds.
* @return JobConfigurationInterface
*/
public function jobTimeoutMs(int $jobTimeoutMs)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Return type here as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same response as above

@Hectorhammett
Copy link
Copy Markdown
Collaborator

We might want to add some tests for this. I would recommend writing a test that mocks the transport layer and checks that the new flag is in there as well as sending it on a System test to see if the server responds with the expected data.

We cannot confirm the server behaviour at times, but just the fact of adding a test that sends the flag helps us keeping regressions to a minimum that being either from code changes from our side or the BigQuery team itself.

@cy-yun cy-yun enabled auto-merge (squash) October 24, 2025 17:51
@bshaffer
Copy link
Copy Markdown
Contributor

This is a feature, as new surfaces are being added. It should be marked with feat in the PR title

@cy-yun
Copy link
Copy Markdown
Contributor Author

cy-yun commented Oct 29, 2025

We might want to add some tests for this. I would recommend writing a test that mocks the transport layer and checks that the new flag is in there as well as sending it on a System test to see if the server responds with the expected data.

We cannot confirm the server behaviour at times, but just the fact of adding a test that sends the flag helps us keeping regressions to a minimum that being either from code changes from our side or the BigQuery team itself.

Please take a look at the tests I've added

@cy-yun cy-yun force-pushed the reservation branch 3 times, most recently from b4cefed to eea52ce Compare October 30, 2025 00:41
$this->assertFalse(isset($job->info()['status']['errorResult']));
}

public function testLoadJobWithReservationAndTimeout()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ran this on a test GCP account and confirmed that it passes.

@cy-yun cy-yun changed the title chore(BigQuery): Add reservation and jobTimeoutMs setters to JobConfigurationTrait feat(BigQuery): Add reservation and jobTimeoutMs setters to JobConfigurationTrait Oct 30, 2025
@cy-yun cy-yun merged commit 235b165 into googleapis:main Nov 4, 2025
26 checks passed
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants