diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITQueryTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITQueryTest.java index f07bffc2d8f..a691fbf78b4 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITQueryTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITQueryTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.Assume.assumeFalse; +import static org.junit.Assume.assumeTrue; import com.google.cloud.ByteArray; import com.google.cloud.Date; @@ -355,7 +356,6 @@ public void bindTimestampNull() { @Test public void bindDate() { - assumeFalse("date type is not supported on POSTGRESQL", dialect.dialect == Dialect.POSTGRESQL); Date d = Date.parseDate("2016-09-18"); Struct row = execute(Statement.newBuilder(selectValueQuery).bind("p1").to(d), Type.date()); assertThat(row.isNull(0)).isFalse(); @@ -364,7 +364,6 @@ public void bindDate() { @Test public void bindDateNull() { - assumeFalse("date type is not supported on POSTGRESQL", dialect.dialect == Dialect.POSTGRESQL); Struct row = execute(Statement.newBuilder(selectValueQuery).bind("p1").to((Date) null), Type.date()); assertThat(row.isNull(0)).isTrue(); @@ -682,13 +681,12 @@ public void bindTimestampArrayNull() { @Test public void bindDateArray() { - assumeFalse("date type is not supported on POSTGRESQL", dialect.dialect == Dialect.POSTGRESQL); Date d1 = Date.parseDate("2016-09-18"); Date d2 = Date.parseDate("2016-09-19"); Struct row = execute( - Statement.newBuilder("SELECT @v").bind("v").toDateArray(asList(d1, d2, null)), + Statement.newBuilder(selectValueQuery).bind("p1").toDateArray(asList(d1, d2, null)), Type.array(Type.date())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDateList(0)).containsExactly(d1, d2, null).inOrder(); @@ -696,10 +694,9 @@ public void bindDateArray() { @Test public void bindDateArrayEmpty() { - assumeFalse("date type is not supported on POSTGRESQL", dialect.dialect == Dialect.POSTGRESQL); Struct row = execute( - Statement.newBuilder("SELECT @v").bind("v").toDateArray(Collections.emptyList()), + Statement.newBuilder(selectValueQuery).bind("p1").toDateArray(Collections.emptyList()), Type.array(Type.date())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDateList(0)).containsExactly(); @@ -707,18 +704,16 @@ public void bindDateArrayEmpty() { @Test public void bindDateArrayNull() { - assumeFalse("date type is not supported on POSTGRESQL", dialect.dialect == Dialect.POSTGRESQL); Struct row = execute( - Statement.newBuilder("SELECT @v").bind("v").toDateArray(null), Type.array(Type.date())); + Statement.newBuilder(selectValueQuery).bind("p1").toDateArray(null), + Type.array(Type.date())); assertThat(row.isNull(0)).isTrue(); } @Test - public void bindNumericArray() { - assumeFalse( - "array numeric binding is not supported on POSTGRESQL", - dialect.dialect == Dialect.POSTGRESQL); + public void bindNumericArrayGoogleStandardSQL() { + assumeTrue(dialect.dialect == Dialect.GOOGLE_STANDARD_SQL); assumeFalse("Emulator does not yet support NUMERIC", EmulatorSpannerHelper.isUsingEmulator()); BigDecimal b1 = new BigDecimal("3.14"); BigDecimal b2 = new BigDecimal("6.626"); @@ -732,10 +727,22 @@ public void bindNumericArray() { } @Test - public void bindNumericArrayEmpty() { - assumeFalse( - "array numeric binding is not supported on POSTGRESQL", - dialect.dialect == Dialect.POSTGRESQL); + public void bindNumericArrayPostgreSQL() { + assumeTrue(dialect.dialect == Dialect.POSTGRESQL); + assumeFalse("Emulator does not yet support NUMERIC", EmulatorSpannerHelper.isUsingEmulator()); + Struct row = + execute( + Statement.newBuilder(selectValueQuery) + .bind("p1") + .toPgNumericArray(asList("3.14", "6.626", null)), + Type.array(Type.pgNumeric())); + assertThat(row.isNull(0)).isFalse(); + assertThat(row.getStringList(0)).containsExactly("3.14", "6.626", null).inOrder(); + } + + @Test + public void bindNumericArrayEmptyGoogleStandardSQL() { + assumeTrue(dialect.dialect == Dialect.GOOGLE_STANDARD_SQL); assumeFalse("Emulator does not yet support NUMERIC", EmulatorSpannerHelper.isUsingEmulator()); Struct row = execute( @@ -748,11 +755,22 @@ public void bindNumericArrayEmpty() { } @Test - public void bindNumericArrayNull() { - assumeFalse( - "array numeric binding is not supported on POSTGRESQL", - dialect.dialect == Dialect.POSTGRESQL); + public void bindNumericArrayEmptyPostgreSQL() { + assumeTrue(dialect.dialect == Dialect.POSTGRESQL); assumeFalse("Emulator does not yet support NUMERIC", EmulatorSpannerHelper.isUsingEmulator()); + Struct row = + execute( + Statement.newBuilder(selectValueQuery) + .bind("p1") + .toPgNumericArray(Collections.emptyList()), + Type.array(Type.pgNumeric())); + assertThat(row.isNull(0)).isFalse(); + assertThat(row.getStringList(0)).containsExactly(); + } + + @Test + public void bindNumericArrayNullGoogleStandardSQL() { + assumeTrue(dialect.dialect == Dialect.GOOGLE_STANDARD_SQL); Struct row = execute( Statement.newBuilder(selectValueQuery).bind("p1").toNumericArray(null), @@ -760,6 +778,16 @@ public void bindNumericArrayNull() { assertThat(row.isNull(0)).isTrue(); } + @Test + public void bindNumericArrayNullPostgreSQL() { + assumeTrue(dialect.dialect == Dialect.POSTGRESQL); + Struct row = + execute( + Statement.newBuilder(selectValueQuery).bind("p1").toPgNumericArray(null), + Type.array(Type.pgNumeric())); + assertThat(row.isNull(0)).isTrue(); + } + @Test public void bindNumericArray_doesNotPreservePrecision() { assumeFalse( @@ -771,7 +799,7 @@ public void bindNumericArray_doesNotPreservePrecision() { Struct row = execute( - Statement.newBuilder("SELECT @v").bind("v").toNumericArray(asList(b1, b2, null)), + Statement.newBuilder(selectValueQuery).bind("p1").toNumericArray(asList(b1, b2, null)), Type.array(Type.numeric())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getBigDecimalList(0)) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITResultSetGetValue.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITResultSetGetValue.java index e48b2f35fd0..68aeb2a0e99 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITResultSetGetValue.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITResultSetGetValue.java @@ -21,7 +21,6 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeFalse; import com.google.cloud.ByteArray; import com.google.cloud.Date; @@ -128,7 +127,17 @@ public static void beforeClass() + "float64 DOUBLE PRECISION," + "numeric NUMERIC," + "string VARCHAR," - + "bytes BYTEA" + + "bytes BYTEA," + + "timestamp TIMESTAMPTZ," + + "date DATE," + + "boolArray BOOL[]," + + "int64Array BIGINT[]," + + "float64Array DOUBLE PRECISION[]," + + "numericArray NUMERIC[]," + + "stringArray VARCHAR[]," + + "bytesArray BYTEA[]," + + "dateArray DATE[]," + + "timestampArray TIMESTAMPTZ[]" + ")")); postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase); } @@ -264,6 +273,32 @@ public void testReadNonNullValuesPostgreSQL() { .to("stringValue") .set("bytes") .to(ByteArray.copyFrom("bytesValue")) + .set("date") + .to(Date.fromYearMonthDay(2021, 1, 2)) + .set("timestamp") + .to(Timestamp.ofTimeSecondsAndNanos(1, 0)) + .set("boolArray") + .toBoolArray(new boolean[] {false, true}) + .set("int64Array") + .toInt64Array(new long[] {100L, 200L}) + .set("float64Array") + .toFloat64Array(new double[] {1000D, 2000D}) + .set("numericArray") + .toNumericArray(Arrays.asList(new BigDecimal("10000"), new BigDecimal("20000"))) + .set("stringArray") + .toStringArray(Arrays.asList("string1", "string2")) + .set("bytesArray") + .toBytesArray( + Arrays.asList(ByteArray.copyFrom("bytes1"), ByteArray.copyFrom("bytes2"))) + .set("timestampArray") + .toTimestampArray( + Arrays.asList( + Timestamp.ofTimeSecondsAndNanos(10, 0), + Timestamp.ofTimeSecondsAndNanos(20, 0))) + .set("dateArray") + .toDateArray( + Arrays.asList( + Date.fromYearMonthDay(2021, 2, 3), Date.fromYearMonthDay(2021, 3, 4))) .build())); try (ResultSet resultSet = @@ -278,6 +313,34 @@ public void testReadNonNullValuesPostgreSQL() { assertEquals(Value.pgNumeric("30"), resultSet.getValue("numeric")); assertEquals(Value.string("stringValue"), resultSet.getValue("string")); assertEquals(Value.bytes(ByteArray.copyFrom("bytesValue")), resultSet.getValue("bytes")); + assertEquals( + Value.timestamp(Timestamp.ofTimeSecondsAndNanos(1, 0)), resultSet.getValue("timestamp")); + assertEquals(Value.date(Date.fromYearMonthDay(2021, 1, 2)), resultSet.getValue("date")); + assertEquals(Value.boolArray(new boolean[] {false, true}), resultSet.getValue("boolarray")); + assertEquals(Value.int64Array(new long[] {100L, 200L}), resultSet.getValue("int64array")); + assertArrayEquals( + new double[] {1000D, 2000D}, + Doubles.toArray(resultSet.getValue("float64array").getFloat64Array()), + 1e-15); + assertEquals( + Value.pgNumericArray(Arrays.asList("10000", "20000")), + resultSet.getValue("numericarray")); + assertEquals( + Value.stringArray(Arrays.asList("string1", "string2")), + resultSet.getValue("stringarray")); + assertEquals( + Value.bytesArray( + Arrays.asList(ByteArray.copyFrom("bytes1"), ByteArray.copyFrom("bytes2"))), + resultSet.getValue("bytesarray")); + assertEquals( + Value.timestampArray( + Arrays.asList( + Timestamp.ofTimeSecondsAndNanos(10, 0), Timestamp.ofTimeSecondsAndNanos(20, 0))), + resultSet.getValue("timestamparray")); + assertEquals( + Value.dateArray( + Arrays.asList(Date.fromYearMonthDay(2021, 2, 3), Date.fromYearMonthDay(2021, 3, 4))), + resultSet.getValue("datearray")); } } @@ -367,12 +430,42 @@ public void testReadNullValuesPostgreSQL() { assertThrows(IllegalStateException.class, () -> resultSet.getValue("string").getString()); assertTrue(resultSet.getValue("bytes").isNull()); assertThrows(IllegalStateException.class, () -> resultSet.getValue("bytes").getBytes()); + assertTrue(resultSet.getValue("timestamp").isNull()); + assertThrows( + IllegalStateException.class, () -> resultSet.getValue("timestamp").getTimestamp()); + assertTrue(resultSet.getValue("date").isNull()); + assertThrows(IllegalStateException.class, () -> resultSet.getValue("date").getDate()); + assertTrue(resultSet.getValue("boolarray").isNull()); + assertThrows( + IllegalStateException.class, () -> resultSet.getValue("boolarray").getBoolArray()); + assertTrue(resultSet.getValue("int64array").isNull()); + assertThrows( + IllegalStateException.class, () -> resultSet.getValue("int64array").getInt64Array()); + assertTrue(resultSet.getValue("float64array").isNull()); + assertThrows( + IllegalStateException.class, () -> resultSet.getValue("float64array").getFloat64Array()); + assertTrue(resultSet.getValue("numericarray").isNull()); + assertThrows( + IllegalStateException.class, () -> resultSet.getValue("numericarray").getNumericArray()); + assertTrue(resultSet.getValue("stringarray").isNull()); + assertThrows( + IllegalStateException.class, () -> resultSet.getValue("stringarray").getStringArray()); + assertTrue(resultSet.getValue("bytesarray").isNull()); + assertThrows( + IllegalStateException.class, () -> resultSet.getValue("bytesarray").getBytesArray()); + assertTrue(resultSet.getValue("timestamparray").isNull()); + assertThrows( + IllegalStateException.class, + () -> resultSet.getValue("timestamparray").getTimestampArray()); + assertTrue(resultSet.getValue("datearray").isNull()); + assertThrows( + IllegalStateException.class, () -> resultSet.getValue("datearray").getDateArray()); } } @Test - public void testReadNullValuesInArrays() { - assumeFalse("PostgreSQL does not yet support Arrays", dialect.dialect == Dialect.POSTGRESQL); + public void testReadNullValuesInArraysGoogleStandardSQL() { + Assume.assumeTrue(dialect.dialect == Dialect.GOOGLE_STANDARD_SQL); databaseClient.write( Collections.singletonList( Mutation.newInsertBuilder(TABLE_NAME) @@ -429,6 +522,59 @@ public void testReadNullValuesInArrays() { } } + @Test + public void testReadNullValuesInArraysPostgreSQL() { + Assume.assumeTrue(dialect.dialect == Dialect.POSTGRESQL); + databaseClient.write( + Collections.singletonList( + Mutation.newInsertBuilder(TABLE_NAME) + .set("Id") + .to(3L) + .set("boolArray") + .toBoolArray(Arrays.asList(true, null)) + .set("int64Array") + .toInt64Array(Arrays.asList(null, 2L)) + .set("float64Array") + .toFloat64Array(Arrays.asList(null, 10D)) + .set("numericArray") + .toNumericArray(Arrays.asList(new BigDecimal("10000"), null)) + .set("stringArray") + .toStringArray(Arrays.asList(null, "string2")) + .set("bytesArray") + .toBytesArray(Arrays.asList(ByteArray.copyFrom("bytes1"), null)) + .set("timestampArray") + .toTimestampArray(Arrays.asList(null, Timestamp.ofTimeSecondsAndNanos(20, 0))) + .set("dateArray") + .toDateArray(Arrays.asList(Date.fromYearMonthDay(2021, 2, 3), null)) + .build())); + + try (ResultSet resultSet = + databaseClient + .singleUse() + .executeQuery(Statement.of("SELECT * FROM " + TABLE_NAME + " WHERE Id = 3"))) { + resultSet.next(); + + assertEquals(Value.int64(3L), resultSet.getValue("id")); + assertEquals(Value.boolArray(Arrays.asList(true, null)), resultSet.getValue("boolarray")); + assertEquals(Value.int64Array(Arrays.asList(null, 2L)), resultSet.getValue("int64array")); + assertNull(resultSet.getValue("float64array").getFloat64Array().get(0)); + assertEquals(10D, resultSet.getValue("float64array").getFloat64Array().get(1), DELTA); + assertEquals( + Value.pgNumericArray(Arrays.asList("10000", null)), resultSet.getValue("numericarray")); + assertEquals( + Value.stringArray(Arrays.asList(null, "string2")), resultSet.getValue("stringarray")); + assertEquals( + Value.bytesArray(Arrays.asList(ByteArray.copyFrom("bytes1"), null)), + resultSet.getValue("bytesarray")); + assertEquals( + Value.timestampArray(Arrays.asList(null, Timestamp.ofTimeSecondsAndNanos(20, 0))), + resultSet.getValue("timestamparray")); + assertEquals( + Value.dateArray(Arrays.asList(Date.fromYearMonthDay(2021, 2, 3), null)), + resultSet.getValue("datearray")); + } + } + @Test public void testReadNonFloat64LiteralsGoogleStandardSQL() { Assume.assumeTrue(dialect.dialect == Dialect.GOOGLE_STANDARD_SQL); @@ -570,7 +716,16 @@ public void testReadNonFloat64LiteralsPostgreSQL() { + "1 AS int64," + "CAST('100' AS numeric) AS numeric," + "'stringValue' AS string," - + "CAST('bytesValue' AS BYTEA) AS bytes"))) { + + "CAST('bytesValue' AS BYTEA) AS bytes," + + "CAST('1970-01-01T00:00:01 UTC' AS TIMESTAMPTZ) AS timestamp," + + "CAST('2021-02-03' AS DATE) AS date," + + "ARRAY[false, true] AS boolArray," + + "ARRAY[1, 2] AS int64Array," + + "ARRAY[CAST('100' AS NUMERIC), CAST('200' AS NUMERIC)] AS numericArray," + + "ARRAY['string1', 'string2'] AS stringArray," + + "ARRAY[CAST('bytes1' AS BYTEA), CAST('bytes2' AS BYTEA)] AS bytesArray," + + "ARRAY[CAST('1970-01-01T00:00:01 UTC' AS TIMESTAMPTZ), CAST('1970-01-01T00:00:02 UTC' AS TIMESTAMPTZ)] AS timestampArray," + + "ARRAY[CAST('2020-01-02' AS DATE), CAST('2021-02-03' AS DATE)] AS dateArray"))) { resultSet.next(); assertEquals(Value.bool(true), resultSet.getValue("bool")); @@ -578,6 +733,29 @@ public void testReadNonFloat64LiteralsPostgreSQL() { assertEquals(Value.pgNumeric("100"), resultSet.getValue("numeric")); assertEquals(Value.string("stringValue"), resultSet.getValue("string")); assertEquals(Value.bytes(ByteArray.copyFrom("bytesValue")), resultSet.getValue("bytes")); + assertEquals( + Value.timestamp(Timestamp.ofTimeSecondsAndNanos(1, 0)), resultSet.getValue("timestamp")); + assertEquals(Value.date(Date.fromYearMonthDay(2021, 2, 3)), resultSet.getValue("date")); + assertEquals(Value.boolArray(new boolean[] {false, true}), resultSet.getValue("boolarray")); + assertEquals(Value.int64Array(new long[] {1L, 2L}), resultSet.getValue("int64array")); + assertEquals( + Value.pgNumericArray(Arrays.asList("100", "200")), resultSet.getValue("numericarray")); + assertEquals( + Value.stringArray(Arrays.asList("string1", "string2")), + resultSet.getValue("stringarray")); + assertEquals( + Value.bytesArray( + Arrays.asList(ByteArray.copyFrom("bytes1"), ByteArray.copyFrom("bytes2"))), + resultSet.getValue("bytesarray")); + assertEquals( + Value.timestampArray( + Arrays.asList( + Timestamp.ofTimeSecondsAndNanos(1, 0), Timestamp.ofTimeSecondsAndNanos(2, 0))), + resultSet.getValue("timestamparray")); + assertEquals( + Value.dateArray( + Arrays.asList(Date.fromYearMonthDay(2020, 1, 2), Date.fromYearMonthDay(2021, 2, 3))), + resultSet.getValue("datearray")); } } @@ -615,9 +793,16 @@ public void testReadFloat64LiteralsGoogleStandardSQL() { public void testReadFloat64LiteralsPostgreSQL() { Assume.assumeTrue(dialect.dialect == Dialect.POSTGRESQL); try (ResultSet resultSet = - databaseClient.singleUse().executeQuery(Statement.of("SELECT 10.0 AS float64"))) { + databaseClient + .singleUse() + .executeQuery( + Statement.of("SELECT 10.0 AS float64, " + "ARRAY[20.0, 30.0] AS float64Array"))) { resultSet.next(); assertEquals(10D, resultSet.getValue("float64").getFloat64(), DELTA); + assertArrayEquals( + new double[] {20D, 30D}, + Doubles.toArray(resultSet.getValue("float64array").getFloat64Array()), + DELTA); } } } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITWriteTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITWriteTest.java index d274cdb91f5..2428e75c994 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITWriteTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITWriteTest.java @@ -126,7 +126,17 @@ public static List data() { + " Float64Value DOUBLE PRECISION," + " StringValue VARCHAR," + " BytesValue BYTEA," - + " NumericValue NUMERIC" + + " TimestampValue TIMESTAMPTZ," + + " DateValue DATE," + + " NumericValue NUMERIC," + + " BoolArrayValue BOOL[]," + + " Int64ArrayValue BIGINT[]," + + " Float64ArrayValue DOUBLE PRECISION[]," + + " StringArrayValue VARCHAR[]," + + " BytesArrayValue BYTEA[]," + + " TimestampArrayValue TIMESTAMPTZ[]," + + " DateArrayValue DATE[]," + + " NumericArrayValue NUMERIC[]" + ")"; private static final String GOOGLE_STANDARD_SQL_SCHEMA_WITHOUT_NUMERIC_AND_JSON = @@ -492,7 +502,6 @@ public void writeTimestamp() { @Test public void writeTimestampNull() { - assumeFalse("PostgreSQL does not yet support Timestamp", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("TimestampValue").to((Timestamp) null).build()); Struct row = readLastRow("TimestampValue"); assertThat(row.isNull(0)).isTrue(); @@ -500,7 +509,8 @@ public void writeTimestampNull() { @Test public void writeCommitTimestamp() { - assumeFalse("PostgreSQL does not yet support Timestamp", dialect.dialect == Dialect.POSTGRESQL); + assumeFalse( + "PostgreSQL does not yet support Commit Timestamp", dialect.dialect == Dialect.POSTGRESQL); Timestamp commitTimestamp = write(baseInsert().set("TimestampValue").to(Value.COMMIT_TIMESTAMP).build()); Struct row = readLastRow("TimestampValue"); @@ -509,7 +519,6 @@ public void writeCommitTimestamp() { @Test public void writeDate() { - assumeFalse("PostgreSQL does not yet support Date", dialect.dialect == Dialect.POSTGRESQL); Date date = Date.parseDate("2016-09-15"); write(baseInsert().set("DateValue").to(date).build()); Struct row = readLastRow("DateValue"); @@ -519,7 +528,6 @@ public void writeDate() { @Test public void writeDateNull() { - assumeFalse("PostgreSQL does not yet support Date", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("DateValue").to((Date) null).build()); Struct row = readLastRow("DateValue"); assertThat(row.isNull(0)).isTrue(); @@ -548,7 +556,6 @@ public void writeNumericNull() { @Test public void writeBoolArrayNull() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("BoolArrayValue").toBoolArray((boolean[]) null).build()); Struct row = readLastRow("BoolArrayValue"); assertThat(row.isNull(0)).isTrue(); @@ -556,7 +563,6 @@ public void writeBoolArrayNull() { @Test public void writeBoolArrayEmpty() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("BoolArrayValue").toBoolArray(new boolean[] {}).build()); Struct row = readLastRow("BoolArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -565,7 +571,6 @@ public void writeBoolArrayEmpty() { @Test public void writeBoolArray() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("BoolArrayValue").toBoolArray(Arrays.asList(true, null, false)).build()); Struct row = readLastRow("BoolArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -580,7 +585,6 @@ public void writeBoolArray() { @Test public void writeBoolArrayNoNulls() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("BoolArrayValue").toBoolArray(Arrays.asList(true, false)).build()); Struct row = readLastRow("BoolArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -589,7 +593,6 @@ public void writeBoolArrayNoNulls() { @Test public void writeInt64ArrayNull() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("Int64ArrayValue").toInt64Array((long[]) null).build()); Struct row = readLastRow("Int64ArrayValue"); assertThat(row.isNull(0)).isTrue(); @@ -597,7 +600,6 @@ public void writeInt64ArrayNull() { @Test public void writeInt64ArrayEmpty() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("Int64ArrayValue").toInt64Array(new long[] {}).build()); Struct row = readLastRow("Int64ArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -606,7 +608,6 @@ public void writeInt64ArrayEmpty() { @Test public void writeInt64Array() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("Int64ArrayValue").toInt64Array(Arrays.asList(1L, 2L, null)).build()); Struct row = readLastRow("Int64ArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -621,7 +622,6 @@ public void writeInt64Array() { @Test public void writeInt64ArrayNoNulls() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("Int64ArrayValue").toInt64Array(Arrays.asList(1L, 2L)).build()); Struct row = readLastRow("Int64ArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -630,7 +630,6 @@ public void writeInt64ArrayNoNulls() { @Test public void writeFloat64ArrayNull() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("Float64ArrayValue").toFloat64Array((double[]) null).build()); Struct row = readLastRow("Float64ArrayValue"); assertThat(row.isNull(0)).isTrue(); @@ -638,7 +637,6 @@ public void writeFloat64ArrayNull() { @Test public void writeFloat64ArrayEmpty() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("Float64ArrayValue").toFloat64Array(new double[] {}).build()); Struct row = readLastRow("Float64ArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -647,7 +645,6 @@ public void writeFloat64ArrayEmpty() { @Test public void writeFloat64Array() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write( baseInsert() .set("Float64ArrayValue") @@ -666,7 +663,6 @@ public void writeFloat64Array() { @Test public void writeFloat64ArrayNoNulls() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("Float64ArrayValue").toFloat64Array(Arrays.asList(1.0, 2.0)).build()); Struct row = readLastRow("Float64ArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -677,7 +673,6 @@ public void writeFloat64ArrayNoNulls() { @Test public void writeStringArrayNull() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("StringArrayValue").toStringArray(null).build()); Struct row = readLastRow("StringArrayValue"); assertThat(row.isNull(0)).isTrue(); @@ -685,7 +680,6 @@ public void writeStringArrayNull() { @Test public void writeStringArrayEmpty() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("StringArrayValue").toStringArray(Collections.emptyList()).build()); Struct row = readLastRow("StringArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -694,7 +688,6 @@ public void writeStringArrayEmpty() { @Test public void writeStringArray() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write( baseInsert().set("StringArrayValue").toStringArray(Arrays.asList("a", null, "b")).build()); Struct row = readLastRow("StringArrayValue"); @@ -753,7 +746,6 @@ public void writeJsonArrayNoNulls() { @Test public void writeBytesArrayNull() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("BytesArrayValue").toBytesArray(null).build()); Struct row = readLastRow("BytesArrayValue"); assertThat(row.isNull(0)).isTrue(); @@ -761,7 +753,6 @@ public void writeBytesArrayNull() { @Test public void writeBytesArrayEmpty() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("BytesArrayValue").toBytesArray(Collections.emptyList()).build()); Struct row = readLastRow("BytesArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -770,7 +761,6 @@ public void writeBytesArrayEmpty() { @Test public void writeBytesArray() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); List data = Arrays.asList(ByteArray.copyFrom("a"), ByteArray.copyFrom("b"), null); write(baseInsert().set("BytesArrayValue").toBytesArray(data).build()); Struct row = readLastRow("BytesArrayValue"); @@ -780,7 +770,6 @@ public void writeBytesArray() { @Test public void writeTimestampArrayNull() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("TimestampArrayValue").toTimestampArray(null).build()); Struct row = readLastRow("TimestampArrayValue"); assertThat(row.isNull(0)).isTrue(); @@ -788,7 +777,6 @@ public void writeTimestampArrayNull() { @Test public void writeTimestampArrayEmpty() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write( baseInsert().set("TimestampArrayValue").toTimestampArray(Collections.emptyList()).build()); Struct row = readLastRow("TimestampArrayValue"); @@ -798,7 +786,6 @@ public void writeTimestampArrayEmpty() { @Test public void writeTimestampArray() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); Timestamp t1 = Timestamp.parseTimestamp("2016-09-18T00:00:00Z"); Timestamp t2 = Timestamp.parseTimestamp("2016-09-19T00:00:00Z"); write( @@ -813,7 +800,6 @@ public void writeTimestampArray() { @Test public void writeDateArrayNull() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("DateArrayValue").toDateArray(null).build()); Struct row = readLastRow("DateArrayValue"); assertThat(row.isNull(0)).isTrue(); @@ -821,7 +807,6 @@ public void writeDateArrayNull() { @Test public void writeDateArrayEmpty() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); write(baseInsert().set("DateArrayValue").toDateArray(Collections.emptyList()).build()); Struct row = readLastRow("DateArrayValue"); assertThat(row.isNull(0)).isFalse(); @@ -830,7 +815,6 @@ public void writeDateArrayEmpty() { @Test public void writeDateArray() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); Date d1 = Date.parseDate("2016-09-18"); Date d2 = Date.parseDate("2016-09-19"); write(baseInsert().set("DateArrayValue").toDateArray(Arrays.asList(d1, null, d2)).build()); @@ -841,7 +825,6 @@ public void writeDateArray() { @Test public void writeNumericArrayNull() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); assumeFalse("Emulator does not yet support NUMERIC", EmulatorSpannerHelper.isUsingEmulator()); write(baseInsert().set("NumericArrayValue").toNumericArray(null).build()); Struct row = readLastRow("NumericArrayValue"); @@ -850,17 +833,19 @@ public void writeNumericArrayNull() { @Test public void writeNumericArrayEmpty() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); assumeFalse("Emulator does not yet support NUMERIC", EmulatorSpannerHelper.isUsingEmulator()); write(baseInsert().set("NumericArrayValue").toNumericArray(ImmutableList.of()).build()); Struct row = readLastRow("NumericArrayValue"); assertThat(row.isNull(0)).isFalse(); - assertThat(row.getBigDecimalList(0)).containsExactly(); + if (dialect.dialect == Dialect.GOOGLE_STANDARD_SQL) { + assertThat(row.getBigDecimalList(0)).containsExactly(); + } else { + assertThat(row.getStringList(0)).containsExactly(); + } } @Test public void writeNumericArray() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); assumeFalse("Emulator does not yet support NUMERIC", EmulatorSpannerHelper.isUsingEmulator()); write( baseInsert() @@ -870,14 +855,16 @@ public void writeNumericArray() { .build()); Struct row = readLastRow("NumericArrayValue"); assertThat(row.isNull(0)).isFalse(); - assertThat(row.getBigDecimalList(0)) - .containsExactly(BigDecimal.valueOf(3141592, 6), BigDecimal.valueOf(6626, 3), null) - .inOrder(); + if (dialect.dialect == Dialect.GOOGLE_STANDARD_SQL) { + assertThat(row.getBigDecimalList(0)) + .containsExactly(BigDecimal.valueOf(3141592, 6), BigDecimal.valueOf(6626, 3), null); + } else { + assertThat(row.getStringList(0)).containsExactly("3.141592", "6.626", null).inOrder(); + } } @Test public void writeNumericArrayNoNulls() { - assumeFalse("PostgreSQL does not yet support Array", dialect.dialect == Dialect.POSTGRESQL); assumeFalse("Emulator does not yet support NUMERIC", EmulatorSpannerHelper.isUsingEmulator()); write( baseInsert() @@ -886,9 +873,15 @@ public void writeNumericArrayNoNulls() { .build()); Struct row = readLastRow("NumericArrayValue"); assertThat(row.isNull(0)).isFalse(); - assertThat(row.getBigDecimalList(0)) - .containsExactly(BigDecimal.valueOf(3141592, 6), BigDecimal.valueOf(6626, 3)) - .inOrder(); + if (dialect.dialect == Dialect.GOOGLE_STANDARD_SQL) { + assertThat(row.getBigDecimalList(0)) + .containsExactly(BigDecimal.valueOf(3141592, 6), BigDecimal.valueOf(6626, 3)); + } else { + assertThat(row.getStringList(0)) + .containsExactly( + BigDecimal.valueOf(3141592, 6).toString(), BigDecimal.valueOf(6626, 3).toString()) + .inOrder(); + } } @Test