use of com.google.cloud.bigquery.ConnectionSettings in project java-bigquery by googleapis.
the class ITBigQueryTest method testExecuteSelectWithPositionalQueryParameters.
/* TODO(prasmish): expand below test case with all the fields shown in the above test case */
@Test
public void testExecuteSelectWithPositionalQueryParameters() throws BigQuerySQLException {
String query = "SELECT TimestampField, StringField FROM " + TABLE_ID.getTable() + " WHERE StringField = ?" + " AND TimestampField > ?";
QueryParameterValue stringParameter = QueryParameterValue.string("stringValue");
QueryParameterValue timestampParameter = QueryParameterValue.timestamp("2014-01-01 07:00:00.000000+00:00");
Parameter stringParam = Parameter.newBuilder().setValue(stringParameter).build();
Parameter timeStampParam = Parameter.newBuilder().setValue(timestampParameter).build();
ConnectionSettings connectionSettings = ConnectionSettings.newBuilder().setDefaultDataset(DatasetId.of(DATASET)).build();
Connection connection = bigquery.createConnection(connectionSettings);
List<Parameter> parameters = ImmutableList.of(stringParam, timeStampParam);
BigQueryResult rs = connection.executeSelect(query, parameters);
assertEquals(2, rs.getTotalRows());
}
Aggregations