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
{{ message }}
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Publish Array of Structure Code sample on the lines of below
public static void queryWithArrayOfStructsNamedParams() {
try {
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests.
BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
// Create struct and add it to the list
Map<String, QueryParameterValue> structMap = new HashMap<>();
structMap.put("stringField", QueryParameterValue.string("test-stringField"));
QueryParameterValue structQueryParam = QueryParameterValue.struct(structMap);
List<QueryParameterValue> aryOfStruct = new ArrayList<>();
aryOfStruct.add(structQueryParam);
String query = "SELECT (@arrayOfStructField) AS record";
QueryJobConfiguration queryConfig =
QueryJobConfiguration.newBuilder(query)
.setUseLegacySql(false)
.addNamedParameter("arrayOfStructField", QueryParameterValue.array(aryOfStruct.toArray(), StandardSQLTypeName.STRING))
.build();
TableResult results = bigquery.query(queryConfig);
results
.iterateAll()
.forEach(row -> row.forEach(val -> System.out.printf("%s", val.toString())));
System.out.println("Query with Array of struct parameter performed successfully.");
} catch (BigQueryException | InterruptedException e) {
System.out.println("Query not performed \n" + e);
}
}
Publish Array of Structure Code sample on the lines of below