You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specify the API at the beginning of the title. For example, "BigQuery: ...").
General, Core, and Other are also allowed as types
OS type and version: macOS 14.7.1
Java version: JDK Zulu 21.0.3
version(s): 2.44.0
Steps to reproduce
Create a BigQuery table that contains a field, which is an ARRAY<STRUCT<subfield STRING>>. E.g.
create table `<project_id>.example.bug` (
people ARRAY<STRUCT<name STRING>>
);
Create a parameterized query, such as:
insert into `<project_id>.example.bug` (people) values (@people);
Prepare the query job configuration (assume a BigQuery service is configured in the snippet below):
data classPerson(valname:String)
val people = emptyList<Person>()
val sql ="insert into `<project_id>.example.bug` (people) values (@people);"val params =mapOf("people" to QueryParameterValue.array(people, StandardSQLTypeName.STRUCT))
val jobConfig =QueryJobConfiguration.newBuilder(sql).setNamedParameters(params).build()
val tableResult = bigQuery.query(jobConfig)
The code above will fail with ``.
Stack trace
com.google.cloud.bigquery.BigQueryException: Value has type ARRAY<STRUCT<>> which cannot be inserted into column must_not_contain, which has type ARRAY<STRUCT<term_regex STRING>> at [7:9]
...
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
POST https://bigquery.googleapis.com/bigquery/v2/projects/bolcom-stg-nostradamus-916/queries
{
"code": 400,
"errors": [
{
"domain": "global",
"location": "q",
"locationType": "parameter",
"message": "Value has type ARRAY<STRUCT<>> which cannot be inserted into column people, which has type ARRAY<STRUCT<name STRING>> at [7:9]",
"reason": "invalidQuery"
}
],
"message": "Value has type ARRAY<STRUCT<>> which cannot be inserted into column people, which has type ARRAY<STRUCT<name STRING>> at [7:9]",
"status": "INVALID_ARGUMENT"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$3.interceptResponse(AbstractGoogleClientRequest.java:479)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:565)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:506)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:616)
at com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.queryRpc(HttpBigQueryRpc.java:771)
... 19 more
Any additional information below
This is caused by the fact that setting the value and the schema are intertwined in the Java SDK. In the Python SDK, this is not the case, an empty array and the corresponding schema can be set individually. See here as a reference.
Proposed resolution
There are two options here:
QueryParameterValue should allow for a separation of schema definition and value. Currently it's not possible to provide the structure of a field without specifying a value.
BigQuery itself should not require the full schema when an empty array is provided to a field that has an ARRAY<STRUCT<subfield STRING>> as a structure.
Thanks!
The text was updated successfully, but these errors were encountered:
Environment details
General, Core, and Other are also allowed as types
Steps to reproduce
ARRAY<STRUCT<subfield STRING>>
. E.g.BigQuery
service is configured in the snippet below):The code above will fail with ``.
Stack trace
Any additional information below
This is caused by the fact that setting the value and the schema are intertwined in the Java SDK. In the Python SDK, this is not the case, an empty array and the corresponding schema can be set individually. See here as a reference.
Proposed resolution
There are two options here:
QueryParameterValue
should allow for a separation of schema definition and value. Currently it's not possible to provide the structure of a field without specifying a value.ARRAY<STRUCT<subfield STRING>>
as a structure.Thanks!
The text was updated successfully, but these errors were encountered: