@Test public void bindTimestampArrayEmpty() { Struct row = execute( Statement.newBuilder("SELECT @v") .bind("v") .toTimestampArray(Arrays.<Timestamp>asList()), Type.array(Type.timestamp())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getTimestampList(0)).containsExactly(); }
@Test public void writeTimestampArrayEmpty() { write( baseInsert() .set("TimestampArrayValue") .toTimestampArray(Arrays.<Timestamp>asList()) .build()); Struct row = readLastRow("TimestampArrayValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getTimestampList(0)).containsExactly(); }
@Test public void bindTimestampArrayNull() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toTimestampArray(null), Type.array(Type.timestamp())); assertThat(row.isNull(0)).isTrue(); }
@Test public void writeTimestampArrayNull() { write(baseInsert().set("TimestampArrayValue").toTimestampArray(null).build()); Struct row = readLastRow("TimestampArrayValue"); assertThat(row.isNull(0)).isTrue(); }
@Test public void bindTimestampArray() { Timestamp t1 = Timestamp.parseTimestamp("2016-09-18T00:00:00Z"); Timestamp t2 = Timestamp.parseTimestamp("2016-09-19T00:00:00Z"); Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toTimestampArray(asList(t1, t2, null)), Type.array(Type.timestamp())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getTimestampList(0)).containsExactly(t1, t2, null).inOrder(); }
@Test public void writeTimestampArray() { Timestamp t1 = Timestamp.parseTimestamp("2016-09-18T00:00:00Z"); Timestamp t2 = Timestamp.parseTimestamp("2016-09-19T00:00:00Z"); write( baseInsert() .set("TimestampArrayValue") .toTimestampArray(Arrays.asList(t1, null, t2)) .build()); Struct row = readLastRow("TimestampArrayValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getTimestampList(0)).containsExactly(t1, null, t2).inOrder(); }
break; case TIMESTAMP: builder.set(fieldName).toTimestampArray((Iterable<Timestamp>) value); break; case DATE:
.toStringArray(null) .set("timestampArr") .toTimestampArray(ImmutableList.of(Timestamp.MAX_VALUE, Timestamp.MAX_VALUE)) .set("timestampArrNull") .toTimestampArray(null) .set("dateArr") .toDateArray(
builder .set(column.name()) .toTimestampArray( readTimestampArray(record, arrayType, arrayLogicalType, fieldName) .orElse(null));
break; case TIMESTAMP: builder.set(fieldName).toTimestampArray((Iterable<Timestamp>) value); break; case DATE:
Mutation.newInsertOrUpdateBuilder("test") .set("one") .toTimestampArray(Arrays.asList(Timestamp.now(), null)) .build(); Mutation dateArray = Mutation.newInsertOrUpdateBuilder("test").set("one").toTimestampArray(null).build(); Mutation nullDateArray = Mutation.newInsertOrUpdateBuilder("test").set("one").toDateArray(null).build();