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

Destination table's schema is not compatible with dataframe's schema. Incompatible max length for field: FIELD_NAME, cannot write source field with max length: null to destination field with max length: 8 #1312

Open
kumarshekhar opened this issue Oct 28, 2024 · 1 comment

Comments

@kumarshekhar
Copy link

I'm getting below error while using parameterized data types in BigQuery https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#parameterized_data_types in a spark java project.

Caused by: java.land.IllegalArgumentException: com.google.cloud.bigquery.connector.common.BigQueryConnectorException$InvalidSchemaException: Destination table's schema is not compatible with dataframe's schema. Incompatible max length for field: FIELD_NAME, cannot write source field with max length: null to destination field with max length: 8

In BigQuery, I have created a table with column FIELD_NAME STRING(8). I'm trying to write to this table using option writeMethod direct using code provided below. Java spark does not provide a way to define StructField with length for a String.

data.write().format(bigquery).mode(SaveMode.Append).option("writeMethod", "direct").option("table", "TABLE_NAME").save();

Is there a workaround to stop the write from failing? I've tried the same code to write to Oracle database, and it worked fine. BigQuery connector is erroring out while comparing the schema of the Row in spark to the schema of the BigQuery table.

spark-bigquery-with-dependencies_2.13 v0.41.0
spark-sql_2.13 v3.5.1

@kumarshekhar
Copy link
Author

@davidrabinowitz @isha97 Is there a workaround to skip the maxlength validation for parameterized data types in BigQuery?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant