Skip to content

query result metadata problem #1362

Closed
Closed
@chartnado-dave-haas

Description

@chartnado-dave-haas

Hello.

We are developing an application the retrieves results from several SQL vendors, including BigQuery.

In the BigQuery case, for authentication we acquire an OAuth token from Google. There are 2 scopes we can use for the token:

  1. /auth/bigquery
  2. /auth/bigquery.readonly

We would prefer to query using the read only scope, since our software should be able to read result sets but not write.

However, we are experiencing an issue with this client library.

If our software acquires the read only scope, we are only able to run the .query(...) library method. The method executes successfully for a valid query but the column metadata of the result set is not provided.

For example (TypeScript)

let query: Query = {
  query: sql
};

// execute the query
let queryResult: SimpleQueryRowsResponse = await connection.query(query);

let rows: any[] = queryResult[0];
let job: bigquery.IJob = queryResult[1];     <- always undefined

console.log(rows);
console.log(job);

In this case we are expecting the IJob to return the column metadata of the result set, however it always returns undefined.

While it appears to make sense that the IJob would be undefined, since we did not actually create a job object, this results in no metadata. In order to determine the schema we have to resort to introspecting the returned rows. However, there appears to be no other way to obtain metadata from the simple .query(...) library method.

If our software acquires the full scope then we can run the .createQueryJob(...) library method, since we are now authorized to create jobs. In this case the result set metadata is provided, however this requires read/write access to the database and we would prefer read only.

We recommend that the .query(...) library method returns a result that includes both rows and column metadata.

OS: Windows 11
NodeJS Version: 20.12.12
Client Library Version: 7.6.1

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/nodejs-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions