Skip to content

Conversation

@alvarowolfx
Copy link
Contributor

@alvarowolfx alvarowolfx commented Sep 18, 2025

This PR introduces the new query client with basic query execution flow (no retries yet) covering the 3 use cases:

  • Running a query using jobs.query and obtaining a Query handler
  • Running a query using jobs.insert and obtaining a Query handler
  • Reattaching to a Query handler from a JobReference

Implements long pooling of job status in the background to mark query as complete.

Towards #1541

@alvarowolfx alvarowolfx requested review from a team as code owners September 18, 2025 16:28
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: bigquery Issues related to the googleapis/nodejs-bigquery API. labels Sep 18, 2025
Copy link
Contributor

@leahecole leahecole left a comment

Choose a reason for hiding this comment

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

Meta comment that I want to have this be in a branch off of preview-9.x for now because I will be using preview-9.x as a release branch


],
"exclude": [
"system-test/fixtures/sample/**/*.ts"
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reasoning behind this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting an error to compile the code, because those fixtures are used for pack-n-play tests.

> @google-cloud/bigquery@0.1.0 compile
> tsc -p . && cp -r protos build/ && minifyProtoJson

system-test/fixtures/sample/src/index.ts:19:168 - error TS2307: Cannot find module '@google-cloud/bigquery' or its corresponding type declarations.

19 import {DatasetServiceClient, JobServiceClient, ModelServiceClient, ProjectServiceClient, RoutineServiceClient, RowAccessPolicyServiceClient, TableServiceClient} from '@google-cloud/bigquery';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another thing is failing is that npm run fix is failing because it's missing "eslint-plugin-prettier", I was going to add to package.json too.

Copy link
Contributor

Choose a reason for hiding this comment

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

I figured out if you remove the added include and the exclude the system tests run fine - I would strongly prefer to not modify this file at all because it's templated. Made suggestion comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Oooo I see why you included it - lint. Ugh! This should probably get changed at the template level imho

Copy link
Contributor

Choose a reason for hiding this comment

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

OH I can get what I want - no changes to this file, if we move query.ts to just be under system-test - would you be okay with that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Another thing is failing is that npm run fix is failing because it's missing "eslint-plugin-prettier", I was going to add to package.json too.

I am not seeing this locally or in CI for other PRs, but I'll keep an eye out for it and try to repro

/**
* QueryClient is a client for running queries in BigQuery.
*/
export class QueryClient {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am feeling skeptical about this being a separate client and I need to think more about what I don't like.

One thing I can think of is that if it is going to be its own separate client, I would want to see if defined more similarly to the other clients - where we have it be a class attribute of the bigQueryClient rather than the other way around

*/
constructor(options?: BigQueryClientOptions) {
this.client = new BigQueryClient(options);
this.projectId = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

could initializing this to empty string cause an issue later? Would initializing it as undefined be a better choice?

These questions may become obsolete if we structure this client like the other ones

if (this.projectId) {
return;
}
const {jobClient} = this.getBigQueryClient();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be having this instead mess with the underlying job client rather than the centralized one?

Thinking about this though, I do now see why you want the knowledge of the centralized BigQueryClient's existence and how you're going to be using it

* Asynchronously iterates over the rows in the query result.
*/
async *[Symbol.asyncIterator](): AsyncGenerator<Row> {
// TODO: implement iterator
Copy link
Contributor

Choose a reason for hiding this comment

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

note to make sure there's a tracking bug

options?: CallOptions,
): Query {
const q = new Query(client);
q.location = response.location ?? '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it actually okay if this is undefined? What are the consequences of setting this to empty string?

"test/*.ts",
"test/**/*.ts",
"system-test/*.ts",
"system-test/**/*.ts",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"system-test/**/*.ts",

Comment on lines +25 to 28
],
"exclude": [
"system-test/fixtures/sample/**/*.ts"
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
],
"exclude": [
"system-test/fixtures/sample/**/*.ts"
]
]


],
"exclude": [
"system-test/fixtures/sample/**/*.ts"
Copy link
Contributor

Choose a reason for hiding this comment

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

I figured out if you remove the added include and the exclude the system tests run fine - I would strongly prefer to not modify this file at all because it's templated. Made suggestion comments


],
"exclude": [
"system-test/fixtures/sample/**/*.ts"
Copy link
Contributor

Choose a reason for hiding this comment

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

Oooo I see why you included it - lint. Ugh! This should probably get changed at the template level imho


],
"exclude": [
"system-test/fixtures/sample/**/*.ts"
Copy link
Contributor

Choose a reason for hiding this comment

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

OH I can get what I want - no changes to this file, if we move query.ts to just be under system-test - would you be okay with that?


],
"exclude": [
"system-test/fixtures/sample/**/*.ts"
Copy link
Contributor

Choose a reason for hiding this comment

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

Another thing is failing is that npm run fix is failing because it's missing "eslint-plugin-prettier", I was going to add to package.json too.

I am not seeing this locally or in CI for other PRs, but I'll keep an eye out for it and try to repro

// See the License for the specific language governing permissions and
// limitations under the License.

import {BigQueryClient, BigQueryClientOptions} from '../bigquery';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import {BigQueryClient, BigQueryClientOptions} from '../bigquery';
import {BigQueryClient} from '../bigquery';

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 googleapis/nodejs-bigquery API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants