use of com.google.cloud.bigquery.BigQueryDryRunResult in project java-bigquery by googleapis.
the class ITBigQueryTest method testConnectionImplDryRun.
@Test
public void testConnectionImplDryRun() throws SQLException {
String query = String.format("select StringField, BigNumericField, BooleanField, BytesField, IntegerField, TimestampField, FloatField, NumericField, TimeField, DateField, DateTimeField , GeographyField, RecordField.BytesField, RecordField.BooleanField, IntegerArrayField from %s where StringField = ? order by TimestampField", TABLE_ID_FASTQUERY_BQ_RESULTSET.getTable());
ConnectionSettings connectionSettings = ConnectionSettings.newBuilder().setDefaultDataset(DatasetId.of(DATASET)).setCreateSession(true).build();
Connection connection = bigquery.createConnection(connectionSettings);
BigQueryDryRunResult bigQueryDryRunResultSet = connection.dryRun(query);
assertNotNull(bigQueryDryRunResultSet.getSchema());
assertEquals(BQ_RESULTSET_EXPECTED_SCHEMA, // match the schema
bigQueryDryRunResultSet.getSchema());
List<Parameter> queryParameters = bigQueryDryRunResultSet.getQueryParameters();
assertEquals(StandardSQLTypeName.STRING, queryParameters.get(0).getValue().getType());
QueryStatistics queryStatistics = bigQueryDryRunResultSet.getStatistics().getQueryStatistics();
assertNotNull(queryStatistics);
SessionInfo sessionInfo = bigQueryDryRunResultSet.getStatistics().getSessionInfo();
assertNotNull(sessionInfo.getSessionId());
assertEquals(StatementType.SELECT, queryStatistics.getStatementType());
}
Aggregations