@Override public List<Date> getDateList(int columnIndex) { return getCurrentRowAsStruct().getDateList(columnIndex); }
@Override public List<Date> getDateList(String columnName) { return getCurrentRowAsStruct().getDateList(columnName); }
@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 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(); }
return Value.float64Array(value.getDoubleArray(fieldIndex)); case DATE: return Value.dateArray(value.getDateList(fieldIndex)); case TIMESTAMP: return Value.timestampArray(value.getTimestampList(fieldIndex));
@Override public List<Date> getDateList(int columnIndex) { return getCurrentRowAsStruct().getDateList(columnIndex); }
@Override public List<Date> getDateList(String columnName) { return getCurrentRowAsStruct().getDateList(columnName); }
return GSON.toJson( currentRow .getDateList(columnName) .stream() .map(Date::toString)
} else { List<String> values = row.getDateList(fieldName) .stream() .map(date -> date == null ? null : date.toString())
return Value.float64Array(value.getDoubleArray(fieldIndex)); case DATE: return Value.dateArray(value.getDateList(fieldIndex)); case TIMESTAMP: return Value.timestampArray(value.getTimestampList(fieldIndex));