use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITReadTest method indexPointRead.
@Test
public void indexPointRead() {
Struct row = client.singleUse(TimestampBound.strong()).readRowUsingIndex(TABLE_NAME, INDEX_NAME, Key.of("v1"), ALL_COLUMNS);
assertThat(row).isNotNull();
assertThat(row.getString(0)).isEqualTo("k1");
assertThat(row.getString(1)).isEqualTo("v1");
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITReadTest method rowsAreSnapshots.
@Test
public void rowsAreSnapshots() {
List<Struct> rows = new ArrayList<>();
ResultSet resultSet = client.singleUse(TimestampBound.strong()).read(TABLE_NAME, KeySet.newBuilder().addKey(Key.of("k2")).addKey(Key.of("k3")).addKey(Key.of("k4")).build(), ALL_COLUMNS);
while (resultSet.next()) {
rows.add(resultSet.getCurrentRowAsStruct());
}
assertThat(rows.size()).isEqualTo(3);
assertThat(rows.get(0).getString(0)).isEqualTo("k2");
assertThat(rows.get(0).getString(1)).isEqualTo("v2");
assertThat(rows.get(1).getString(0)).isEqualTo("k3");
assertThat(rows.get(1).getString(1)).isEqualTo("v3");
assertThat(rows.get(2).getString(0)).isEqualTo("k4");
assertThat(rows.get(2).getString(1)).isEqualTo("v4");
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITReadTest method pointReadNotFound.
@Test
public void pointReadNotFound() {
Struct row = client.singleUse(TimestampBound.strong()).readRow(TABLE_NAME, Key.of("k999"), ALL_COLUMNS);
assertThat(row).isNull();
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method bindBoolArrayNull.
@Test
public void bindBoolArrayNull() {
Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").toBoolArray((boolean[]) null), Type.array(Type.bool()));
assertThat(row.isNull(0)).isTrue();
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method bindTimestamp.
@Test
public void bindTimestamp() {
Timestamp t = Timestamp.parseTimestamp("2016-09-18T00:00:00Z");
Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to(t), Type.timestamp());
assertThat(row.isNull(0)).isFalse();
assertThat(row.getTimestamp(0)).isEqualTo(t);
}
Aggregations