ERROR when setting precision and scale for BIGNUMERIC data type in Big Query schema using python

Viewed 83

I am running my python code in a GCP DataProc cluster and using the spark-bigquery-with-dependencies_2.12-0.24.2.jar file. I am trying to create a table in BigQuery using the python client library as below:

from google.cloud import bigquery


client = bigquery.Client()

table_id = "some_project.some_dataset.some_table_name"
schema = [
    bigquery.SchemaField("full_name", "STRING", mode="REQUIRED"),
    bigquery.SchemaField("salary", "BIGNUMERIC", precision=38, scale=2),
]

table = bigquery.Table(table_id, schema=schema)
table = client.create_table(table)

I get an error like this TypeError: __init__() got an unexpected keyword 'precision'

1 Answers

This might be occurring because the object BIGNUMERIC does not have the correct values, you can try to use it in the following format

“BIGNUMERIC”, (38,2)

Update: I replicated your issue and I was able to set up the precision and the scale for BIGNUMERIC, as mentioned it was due to the format you are calling it, could you try to run it but without the ( ), this seemed to be the issue, at least on my side.

Related