use of com.google.spanner.v1.ResultSetStats in project google-cloud-java by GoogleCloudPlatform.
the class GrpcResultSetTest method profileResultInExtraFinalResultSet.
@Test
public void profileResultInExtraFinalResultSet() {
Map<String, com.google.protobuf.Value> statsMap = ImmutableMap.of("f1", Value.string("").toProto(), "f2", Value.string("").toProto());
ResultSetStats stats = ResultSetStats.newBuilder().setQueryPlan(QueryPlan.newBuilder().build()).setQueryStats(com.google.protobuf.Struct.newBuilder().putAllFields(statsMap).build()).build();
ArrayList<Type.StructField> dataType = new ArrayList<>();
dataType.add(Type.StructField.of("data", Type.string()));
consumer.onPartialResultSet(PartialResultSet.newBuilder().setMetadata(makeMetadata(Type.struct(dataType))).addValues(Value.string("d1").toProto()).setChunkedValue(false).build());
consumer.onPartialResultSet(PartialResultSet.newBuilder().setMetadata(makeMetadata(Type.struct(dataType))).setChunkedValue(false).setStats(stats).build());
resultSet = resultSetWithMode(QueryMode.PROFILE);
consumer.onCompleted();
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.next()).isFalse();
ResultSetStats receivedStats = resultSet.getStats();
assertThat(stats).isEqualTo(receivedStats);
resultSet.close();
}
use of com.google.spanner.v1.ResultSetStats in project google-cloud-java by GoogleCloudPlatform.
the class GrpcResultSetTest method statsNotSupportedError.
@Test
public void statsNotSupportedError() {
ResultSetStats stats = ResultSetStats.newBuilder().build();
consumer.onPartialResultSet(PartialResultSet.newBuilder().setMetadata(makeMetadata(Type.struct(new ArrayList<Type.StructField>()))).setChunkedValue(false).setStats(stats).build());
resultSet = resultSetWithMode(QueryMode.NORMAL);
consumer.onCompleted();
expectedException.expect(UnsupportedOperationException.class);
expectedException.expectMessage("ResultSetStats are available only in PLAN and PROFILE execution modes");
resultSet.getStats();
}
Aggregations