googleapis / nodejs-bigquery

Node.js client for Google Cloud BigQuery: A fast, economical and fully-managed enterprise data warehouse for large-scale data analytics.
https://cloud.google.com/bigquery/
Apache License 2.0
468 stars 211 forks source link

fix: change startIndex option type from string to number #1351

Closed arjunmehta closed 7 months ago

arjunmehta commented 7 months ago

startIndex should be an 0-indexed integer. But as it is was expecting a string which is incorrect and caused a lot of confusion, preventing compilation and requiring odd workarounds.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

Fixes #1350 🙏

google-cla[bot] commented 7 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

conventional-commit-lint-gcf[bot] commented 7 months ago

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot https://conventionalcommits.org/

alvarowolfx commented 7 months ago

this file should not be manually modified, as it is generated from the Discovery doc (with the command npm run types).

arjunmehta commented 7 months ago

@alvarowolfx Ah got it, I will close this PR then but the issue remains open. I am happy to contribute a solution, but not sure where to find/update the relevant Discovery Doc definition. If you want to point me to it I can attempt. Or someone who knows the procedure might be better suited to make the quick fix.

alvarowolfx commented 7 months ago

@alvarowolfx Ah got it, I will close this PR then but the issue remains open. I am happy to contribute a solution, but not sure where to find/update the relevant Discovery Doc definition. If you want to point me to it I can attempt. Or someone who knows the procedure might be better suited to make the quick fix.

the Discovery document represents the backend/API definition, so it can only be changed by the service side itself. In this case, would be a change on the BigQuery backend.

What can be done is to change the generated code to take into consideration the format field of the Discovery doc, not just the type field. But in the end what the service side accepts is a string, so some conversion would have to happen.

alvarowolfx commented 7 months ago

Another thing to consider is that the startIndex attribute expects an uint64 and that can't be represented with a integer in Javascript, which holds at most 2^53 - 1. So users would have to use a BigInt and convert to string anyway.