Search in sources :

Example 76 with Struct

use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.

the class ITQueryTest method nonNumberArray.

@Test
public void nonNumberArray() {
    Struct row = execute(Statement.newBuilder("SELECT [IEEE_DIVIDE(1, 0), IEEE_DIVIDE(-1, 0), IEEE_DIVIDE(0, 0)]"), Type.array(Type.float64()));
    assertThat(row.getDoubleList(0)).hasSize(3);
    assertThat(row.getDoubleList(0).get(0)).isPositiveInfinity();
    assertThat(row.getDoubleList(0).get(1)).isNegativeInfinity();
    assertThat(row.getDoubleList(0).get(2)).isNaN();
}
Also used : Struct(com.google.cloud.spanner.Struct) IntegrationTest(com.google.cloud.spanner.IntegrationTest) Test(org.junit.Test)

Example 77 with Struct

use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.

the class ITQueryTest method bindFloat64Array.

@Test
public void bindFloat64Array() {
    Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").toFloat64Array(Arrays.asList(null, 1.0, 2.0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN)), Type.array(Type.float64()));
    assertThat(row.isNull(0)).isFalse();
    assertThat(row.getDoubleList(0)).containsExactly(null, 1.0, 2.0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN).inOrder();
}
Also used : Struct(com.google.cloud.spanner.Struct) IntegrationTest(com.google.cloud.spanner.IntegrationTest) Test(org.junit.Test)

Example 78 with Struct

use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.

the class ITQueryTest method bindBytesArray.

@Test
public void bindBytesArray() {
    ByteArray e1 = ByteArray.copyFrom("x");
    ByteArray e2 = ByteArray.copyFrom("y");
    ByteArray e3 = null;
    Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").toBytesArray(Arrays.asList(e1, e2, e3)), Type.array(Type.bytes()));
    assertThat(row.isNull(0)).isFalse();
    assertThat(row.getBytesList(0)).containsExactly(e1, e2, e3).inOrder();
}
Also used : ByteArray(com.google.cloud.ByteArray) Struct(com.google.cloud.spanner.Struct) IntegrationTest(com.google.cloud.spanner.IntegrationTest) Test(org.junit.Test)

Example 79 with Struct

use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.

the class ITQueryTest method bindFloat64ArrayEmpty.

@Test
public void bindFloat64ArrayEmpty() {
    Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").toFloat64Array(Arrays.<Double>asList()), Type.array(Type.float64()));
    assertThat(row.isNull(0)).isFalse();
    assertThat(row.getDoubleList(0)).containsExactly();
}
Also used : Struct(com.google.cloud.spanner.Struct) IntegrationTest(com.google.cloud.spanner.IntegrationTest) Test(org.junit.Test)

Example 80 with Struct

use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.

the class ITQueryTest method bindDateNull.

@Test
public void bindDateNull() {
    Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to((Date) null), Type.date());
    assertThat(row.isNull(0)).isTrue();
}
Also used : Date(com.google.cloud.Date) Struct(com.google.cloud.spanner.Struct) IntegrationTest(com.google.cloud.spanner.IntegrationTest) Test(org.junit.Test)

Aggregations

Struct (com.google.cloud.spanner.Struct)106 IntegrationTest (com.google.cloud.spanner.IntegrationTest)101 Test (org.junit.Test)101 Timestamp (com.google.cloud.Timestamp)9 ReadOnlyTransaction (com.google.cloud.spanner.ReadOnlyTransaction)9 Date (com.google.cloud.Date)6 ByteArray (com.google.cloud.ByteArray)5 TimestampBound (com.google.cloud.spanner.TimestampBound)5 TransactionContext (com.google.cloud.spanner.TransactionContext)4 Type (com.google.cloud.spanner.Type)4 SpannerException (com.google.cloud.spanner.SpannerException)3 SpannerExceptionFactory.newSpannerException (com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException)3 TransactionCallable (com.google.cloud.spanner.TransactionRunner.TransactionCallable)3 AbortedException (com.google.cloud.spanner.AbortedException)2 ResultSet (com.google.cloud.spanner.ResultSet)2 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Ignore (org.junit.Ignore)2 TransactionRunner (com.google.cloud.spanner.TransactionRunner)1