use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method bindFloat64.
@Test
public void bindFloat64() {
Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to(2.0), Type.float64());
assertThat(row.isNull(0)).isFalse();
assertThat(row.getDouble(0)).isWithin(0.0).of(2.0);
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method notANumber.
@Test
public void notANumber() {
Struct row = execute(Statement.newBuilder("SELECT IEEE_DIVIDE(0, 0)"), Type.float64());
assertThat(row.getDouble(0)).isNaN();
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method arrayOfStructEmpty.
@Test
public void arrayOfStructEmpty() {
Type structType = Type.struct(StructField.of("", Type.string()), StructField.of("", Type.int64()));
Struct row = execute(Statement.of("SELECT ARRAY(SELECT AS STRUCT * FROM (SELECT 'a', 1) WHERE 0 = 1)"), Type.array(structType));
assertThat(row.isNull(0)).isFalse();
List<Struct> value = row.getStructList(0);
assertThat(value.size()).isEqualTo(0);
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method bindDateArrayEmpty.
@Test
public void bindDateArrayEmpty() {
Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").toDateArray(Arrays.<Date>asList()), Type.array(Type.date()));
assertThat(row.isNull(0)).isFalse();
assertThat(row.getDateList(0)).containsExactly();
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method bindInt64ArrayEmpty.
@Test
public void bindInt64ArrayEmpty() {
Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").toInt64Array(Arrays.<Long>asList()), Type.array(Type.int64()));
assertThat(row.isNull(0)).isFalse();
assertThat(row.getLongList(0)).containsExactly();
}
Aggregations