@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(); }
@Test public void writeDateArrayEmpty() { write(baseInsert().set("DateArrayValue").toDateArray(Arrays.<Date>asList()).build()); Struct row = readLastRow("DateArrayValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDateList(0)).containsExactly(); }
@Test public void bindDateArrayNull() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toDateArray(null), Type.array(Type.date())); assertThat(row.isNull(0)).isTrue(); }
@Test public void writeDateArray() { 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()); Struct row = readLastRow("DateArrayValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDateList(0)).containsExactly(d1, null, d2).inOrder(); }
@Test public void bindDateArray() { 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)), Type.array(Type.date())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDateList(0)).containsExactly(d1, d2, null).inOrder(); }
@Test public void writeDateArrayNull() { write(baseInsert().set("DateArrayValue").toDateArray(null).build()); Struct row = readLastRow("DateArrayValue"); assertThat(row.isNull(0)).isTrue(); }
break; case DATE: builder.set(fieldName).toDateArray((Iterable<Date>) value); break; case STRUCT:
.toTimestampArray(null) .set("dateArr") .toDateArray( ImmutableList.of( Date.fromYearMonthDay(2017, 04, 17), Date.fromYearMonthDay(2017, 04, 18))) .set("dateArrNull") .toDateArray(null);
builder .set(column.name()) .toDateArray(readDateArray(record, arrayType, fieldName).orElse(null)); break; default:
break; case DATE: builder.set(fieldName).toDateArray((Iterable<Date>) value); break; case STRUCT:
Mutation.newInsertOrUpdateBuilder("test") .set("one") .toDateArray( Arrays.asList( null, Mutation.newInsertOrUpdateBuilder("test").set("one").toTimestampArray(null).build(); Mutation nullDateArray = Mutation.newInsertOrUpdateBuilder("test").set("one").toDateArray(null).build();