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

Bug in table.getRows when using different selectedFields in consecutive calls #1433

Open
7 tasks done
jonathan-lande-cyera opened this issue Jan 7, 2025 · 0 comments
Open
7 tasks done
Assignees
Labels
api: bigquery Issues related to the googleapis/nodejs-bigquery API. priority: p2 Moderately-important priority. Fix may not be included in next release.

Comments

@jonathan-lande-cyera
Copy link

jonathan-lande-cyera commented Jan 7, 2025

Please make sure you have searched for information in the following guides.

A screenshot that you have tested with "Try this API".

https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa

image

Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.

https://gist.github.com/jonathan-lande-cyera/900eba3c30f58394ad2bffe4f5d2dffa
OR
https://github.com/jonathan-lande-cyera/nodejs-bigquery/blob/a9b6215aecd3227e009f6808c798f4661754ab55/test/table.ts#L2193C1-L2233C8

A step-by-step description of how to reproduce the issue, based on the linked reproduction.

  1. Copy code from gist into test/table.ts under describe('getRows')
  2. Run test "should return selected fields after consecutive requests"
  3. The test fails and an exception is raised

A clear and concise description of what the bug is, and what you expected to happen.

When calling table.getRows more than once, each time with different selectedFields - the method fails with:

TypeError: Cannot read properties of undefined (reading 'mode')
      at <anonymous> (src/bigquery.ts:615:25)
      at Array.map (<anonymous>)
      at mergeSchema (src/bigquery.ts:612:21)
      at Array.map (<anonymous>)
      at Function.mergeSchemaWithRows_ (src/bigquery.ts:609:25)
      at onComplete (src/table.ts:1843:23)
      at <anonymous> (src/table.ts:1891:9)
      at Table.table.request (test/table.ts:2220:11)
      at Table.getRows (src/table.ts:1860:10)
      at Table.wrapper (node_modules/@google-cloud/promisify/build/src/index.js:30:35)
      at Context.<anonymous> (test/table.ts:2222:15)
      at process.processImmediate (node:internal/timers:476:21)
      at process.callbackTrampoline (node:internal/async_hooks:128:17)

It looks like the table object's metadata.schema.fields is affected by the previous call to getRows and becomes an empty array on the second call, causing the method to fail.

A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **

Calling getRows with valid selectedFields values corresponding to existing columns in the table shouldn't throw an exception.

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/nodejs-bigquery API. label Jan 7, 2025
@alvarowolfx alvarowolfx self-assigned this Jan 8, 2025
@alvarowolfx alvarowolfx added the priority: p2 Moderately-important priority. Fix may not be included in next release. label Jan 8, 2025
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. priority: p2 Moderately-important priority. Fix may not be included in next release.
Projects
None yet
Development

No branches or pull requests

2 participants