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

type JSONList in json_writer is not exported #421

Closed
huilingwei opened this issue Feb 27, 2024 · 4 comments
Closed

type JSONList in json_writer is not exported #421

huilingwei opened this issue Feb 27, 2024 · 4 comments
Assignees
Labels
api: bigquerystorage Issues related to the googleapis/nodejs-bigquery-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@huilingwei
Copy link

Hi,

I am using the JSONWriter appendRows to insert data to Big Query, it accept JSONList as input, but this type is not exported. It is convenient to convert the input to the correct data type. Is it possible to export this type in future release?

Thanks,
Huiling

@huilingwei huilingwei added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Feb 27, 2024
@product-auto-label product-auto-label bot added the api: bigquerystorage Issues related to the googleapis/nodejs-bigquery-storage API. label Feb 27, 2024
@alvarowolfx alvarowolfx self-assigned this Feb 28, 2024
@alvarowolfx alvarowolfx added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p3 Desirable enhancement or fix. May not be included in next release. labels Feb 28, 2024
@alvarowolfx
Copy link
Contributor

hey @huilingwei thanks for the report. The JSONList is suppose to represent just a list of plain JSON objects. Are you having issues passing such objects to the method ? I was holding back exporting those because they are suppose to be a broader type and not reused in other places, unless is causing problems for users to use it.

@galah92
Copy link

galah92 commented Feb 28, 2024

@alvarowolfx any reason not to use TypeScript's object[]? I understand it should be equal to JSONList.

@huilingwei
Copy link
Author

hey @huilingwei thanks for the report. The JSONList is suppose to represent just a list of plain JSON objects. Are you having issues passing such objects to the method ? I was holding back exporting those because they are suppose to be a broader type and not reused in other places, unless is causing problems for users to use it.

We define a common method to insert records, it will accept object[], when writer.appendRows with rows, build will fail for error: Argument of type T[] is not assignable to parameter of type JSONList
We resolve it by converting rows to never[]: writer.appendRows(rows as never[]) . If JSONList is exported, convert the type to JSONList will be better.

const insertCommon = async <T extends object>(
    tableId: string,
    rows: T[],
): Promise<boolean> =>{
  ...
  const pw = writer.appendRows(rows);
  ...
}

@alvarowolfx
Copy link
Contributor

alvarowolfx commented Mar 20, 2024

#422 exports JSONList

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquerystorage Issues related to the googleapis/nodejs-bigquery-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants