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: integrate jobs.query and stateless query for faster queries #1337

Merged
merged 13 commits into from
Mar 27, 2024
Merged
Prev Previous commit
Next Next commit
fix: lint issues
  • Loading branch information
alvarowolfx committed Mar 12, 2024
commit bce8c4866b66b38c257843eef595f1f90184ea71
57 changes: 28 additions & 29 deletions test/bigquery.ts
Expand Up @@ -2143,14 +2143,15 @@ describe('BigQuery', () => {
it('should allow for optional parameter types', () => {
const queryParameter = {};

sandbox.replace(BigQuery, 'valueToQueryParameter_', (
value: {},
providedType: string
) => {
assert.strictEqual(value, NAMED_PARAMS.key);
assert.strictEqual(providedType, NAMED_TYPES.key);
return queryParameter;
});
sandbox.replace(
BigQuery,
'valueToQueryParameter_',
(value: {}, providedType: string) => {
assert.strictEqual(value, NAMED_PARAMS.key);
assert.strictEqual(providedType, NAMED_TYPES.key);
return queryParameter;
}
);
bq.createJob = (reqOpts: JobOptions) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
assert.strictEqual((reqOpts as any).params, undefined);
Expand Down Expand Up @@ -2898,27 +2899,25 @@ describe('BigQuery', () => {
callback(null, fakeJob, {
jobComplete: true,
schema: {
fields: [
{name: 'value', type: 'INT64'}
]
fields: [{name: 'value', type: 'INT64'}],
},
rows: [
{f: [{v: 1}]},
{f: [{v: 2}]},
{f: [{v: 3}]},
],
rows: [{f: [{v: 1}]}, {f: [{v: 2}]}, {f: [{v: 3}]}],
});
};

bq.query(QUERY_STRING, (err: Error, rows: {}, resp: {}) => {
assert.ifError(err);
assert.deepStrictEqual(rows, [{
value: 1,
},{
value: 2
},{
value: 3
}]);
assert.deepStrictEqual(rows, [
{
value: 1,
},
{
value: 2,
},
{
value: 3,
},
]);
assert.strictEqual(resp, FAKE_RESPONSE);
done();
});
Expand Down Expand Up @@ -3023,7 +3022,7 @@ describe('BigQuery', () => {
},
};
const req = bq.buildQueryRequest_(q, {});
for (let key in req) {
for (const key in req) {
if (req[key] === undefined) {
delete req[key];
}
Expand Down Expand Up @@ -3063,7 +3062,7 @@ describe('BigQuery', () => {

it('should create a QueryRequest from a SQL string', () => {
const req = bq.buildQueryRequest_(QUERY_STRING, {});
for (let key in req) {
for (const key in req) {
if (req[key] === undefined) {
delete req[key];
}
Expand Down Expand Up @@ -3116,7 +3115,7 @@ describe('BigQuery', () => {
},
{
query: QUERY_STRING,
jobId: 'fixed-job-id'
jobId: 'fixed-job-id',
},
{
query: QUERY_STRING,
Expand All @@ -3125,11 +3124,11 @@ describe('BigQuery', () => {
},
{
query: QUERY_STRING,
schemaUpdateOptions: ['update']
}
schemaUpdateOptions: ['update'],
},
];

for (let index in testCases) {
for (const index in testCases) {
const testCase = testCases[index];
const req = bq.buildQueryRequest_(testCase, {});
assert.equal(req, undefined);
Expand Down