Skip to content

BigQuery Tools is returning fraction number in json payload #1194

@philippe-batardiere-sada

Description

Prerequisites

Question

Hello,

I've noticed that BigQuery tools return fractions in the JSON payload when NUMERIC type is provided. For example, "95/10" instead of 9.5. I would like to confirm this is expected and switching to float is the only way to avoid this?

Thanks,

Philippe

Code

Here is the code to reproduce the fraction payload

Create the following table with numeric content:

CREATE TABLE tmp.test_fraction(
  id INTEGER NOT NULL,
  numeric_value NUMERIC NOT NULL
);

INSERT INTO tmp.test_fraction
SELECT 1, CAST(9.5 AS NUMERIC)
UNION ALL
SELECT 2, CAST(1/3 AS NUMERIC)
UNION ALL
SELECT 3, CAST(1.0 AS NUMERIC)
UNION ALL
SELECT 4, CAST(1234.10 AS NUMERIC)

Define the following tool:

sources:
  test-bigquery-source:
    kind: bigquery
    project: ${GOOGLE_CLOUD_PROJECT}
    location: us
tools:
  # ---- Entity Lookup Tools ----
  test-fraction:
    kind: bigquery-sql
    source: test-bigquery-source
    description: "Test a fraction"
    statement: >-
      SELECT *
      FROM tmp.test_fraction
toolsets:
  test:
    - test-fraction
Image

Additional Details

No response

Metadata

Metadata

Labels

priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.product: bigqueryBigQuerytype: questionRequest for information or clarification.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions