use of com.google.cloud.spanner.Statement in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method analyzePlan.
@Test
public void analyzePlan() {
Statement statement = Statement.of("SELECT 1 AS column UNION ALL SELECT 2");
ResultSet resultSet = statement.analyzeQuery(client.singleUse(TimestampBound.strong()), QueryAnalyzeMode.PLAN);
assertThat(resultSet.next()).isFalse();
assertThat(resultSet.getType()).isEqualTo(Type.struct(StructField.of("column", Type.int64())));
ResultSetStats receivedStats = resultSet.getStats();
assertThat(receivedStats).isNotNull();
assertThat(receivedStats.hasQueryPlan()).isTrue();
assertThat(receivedStats.hasQueryStats()).isFalse();
}
use of com.google.cloud.spanner.Statement in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method analyzeProfile.
@Test
public void analyzeProfile() {
Statement statement = Statement.of("SELECT 1 AS column UNION ALL SELECT 2 AS column ORDER BY column");
ResultSet resultSet = statement.analyzeQuery(client.singleUse(TimestampBound.strong()), QueryAnalyzeMode.PROFILE);
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getType()).isEqualTo(Type.struct(StructField.of("column", Type.int64())));
assertThat(resultSet.getLong(0)).isEqualTo(1);
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getLong(0)).isEqualTo(2);
assertThat(resultSet.next()).isFalse();
ResultSetStats receivedStats = resultSet.getStats();
assertThat(receivedStats).isNotNull();
assertThat(receivedStats.hasQueryPlan()).isTrue();
assertThat(receivedStats.hasQueryStats()).isTrue();
}
Aggregations