-
Notifications
You must be signed in to change notification settings - Fork 130
Closed
Labels
api: bigqueryIssues related to the googleapis/java-bigquery API.Issues related to the googleapis/java-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.samplesIssues that are directly related to samples.Issues that are directly related to samples.
Description
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);
}
}
Metadata
Metadata
Assignees
Labels
api: bigqueryIssues related to the googleapis/java-bigquery API.Issues related to the googleapis/java-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.samplesIssues that are directly related to samples.Issues that are directly related to samples.