KEMBAR78
Using JsonStreamWriter for Numeric Types · Issue #1757 · googleapis/java-bigquerystorage · GitHub
Skip to content

Using JsonStreamWriter for Numeric Types #1757

@justin-zhang-exa

Description

@justin-zhang-exa

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: bigquerystorageIssues related to the googleapis/java-bigquerystorage API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions