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

Using JsonStreamWriter for Numeric Types #1757

Closed
justin-zhang-exa opened this issue Aug 19, 2022 · 0 comments · Fixed by #1768
Closed

Using JsonStreamWriter for Numeric Types #1757

justin-zhang-exa opened this issue Aug 19, 2022 · 0 comments · Fixed by #1768
Labels
api: bigquerystorage Issues related to the googleapis/java-bigquerystorage API.

Comments

@justin-zhang-exa
Copy link

Steps to reproduce

  1. Have a BigQuery table with the following field (make sure the type=NUMERIC):
    Field{name=risk_level, type=NUMERIC, mode=null, description=null, policyTags=null, maxLength=null, scale=null, precision=null}

  2. Use boilerplate code to set up JsonStreamWriter.

  3. Call append with an object that has the field above and provide a double. For example: [{"risk_level":2.3}]

Code example

        try {
            JSONObject row = new JSONObject().append("risk_level", 2.3);
            JSONArray batch = new JSONArray();
            batch.put(row);

            boilerplateWriteToTable(batch, "project_name");
        } catch(Exceptions.AppendSerializtionError e) {
            System.out.println(e.getRowIndexToErrorMessage());
            throw e;
        }

Stack trace

getRowIndexToErrorMessage Result:

{0=Field root.risk_level failed to convert to NUMERIC. Error: ByteString scale cannot exceed 9: 2.29999999999999982236431605997495353221893310546875}
@product-auto-label product-auto-label bot added the api: bigquerystorage Issues related to the googleapis/java-bigquerystorage API. label Aug 19, 2022
sandhusanthakumar added a commit to sandhusanthakumar/java-bigquerystorage that referenced this issue Aug 29, 2022
sandhusanthakumar added a commit to sandhusanthakumar/java-bigquerystorage that referenced this issue Aug 30, 2022
sandhusanthakumar added a commit to sandhusanthakumar/java-bigquerystorage that referenced this issue Aug 30, 2022
gcf-merge-on-green bot pushed a commit that referenced this issue Sep 15, 2022
🤖 I have created a release *beep* *boop*
---


## [2.21.0](v2.20.1...v2.21.0) (2022-09-15)


### Features

* Add connection worker skeleton used for multiplexing client ([#1778](#1778)) ([b26265e](b26265e))
* Add Load api for connection worker for multiplexing worker ([#1779](#1779)) ([179930e](179930e))
* Add location to WriteStream and add WriteStreamView support ([#1771](#1771)) ([f446ff4](f446ff4))
* Add proto annotation for non-ascii field mapping ([#1776](#1776)) ([1a079ee](1a079ee))
* introducing connection worker to run a loop for fetching / sending requests in a queue. ([7dd447d](7dd447d))


### Bug Fixes

* **api:** Numeric/bignumeric conversion issue [#1757](#1757) ([#1768](#1768)) ([5cc96a0](5cc96a0))


### Dependencies

* Update dependency com.google.cloud:google-cloud-bigquery to v2.15.0 ([#1766](#1766)) ([40e0ba0](40e0ba0))
* Update dependency com.google.cloud:google-cloud-bigquery to v2.16.0 ([#1777](#1777)) ([08a7c8f](08a7c8f))
* Update dependency com.google.cloud:google-cloud-bigquery to v2.16.1 ([#1781](#1781)) ([7ff7099](7ff7099))
* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.2 ([#1772](#1772)) ([3279ef4](3279ef4))
* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 ([#1780](#1780)) ([ed2cd66](ed2cd66))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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/java-bigquerystorage API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant