@Override public List<String> getStringList(int columnIndex) { return getCurrentRowAsStruct().getStringList(columnIndex); }
@Override public List<String> getStringList(String columnName) { return getCurrentRowAsStruct().getStringList(columnName); }
@Test public void writeStringArrayEmpty() { write(baseInsert().set("StringArrayValue").toStringArray(Arrays.<String>asList()).build()); Struct row = readLastRow("StringArrayValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getStringList(0)).containsExactly(); }
@Test public void bindStringArrayEmpty() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toStringArray(Arrays.<String>asList()), Type.array(Type.string())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getStringList(0)).containsExactly(); }
@Test public void bindStringArray() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toStringArray(asList("a", "b", null)), Type.array(Type.string())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getStringList(0)).containsExactly("a", "b", null).inOrder(); }
@Test public void writeStringArray() { write( baseInsert().set("StringArrayValue").toStringArray(Arrays.asList("a", null, "b")).build()); Struct row = readLastRow("StringArrayValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getStringList(0)).containsExactly("a", null, "b").inOrder(); }
private List<?> getRawList(Struct actualRow, int index, Type elementType) throws Exception { List<?> rawList = null; switch (elementType.getCode()) { case BOOL: rawList = actualRow.getBooleanList(index); break; case STRING: rawList = actualRow.getStringList(index); break; case BYTES: rawList = actualRow.getBytesList(index); break; case INT64: rawList = actualRow.getLongList(index); break; case FLOAT64: rawList = actualRow.getDoubleList(index); break; case STRUCT: rawList = actualRow.getStructList(index); break; default: Assert.fail("Unexpected type code:" + elementType.getCode()); } return rawList; }
return Value.int64Array(value.getLongArray(fieldIndex)); case STRING: return Value.stringArray(value.getStringList(fieldIndex)); case BYTES: return Value.bytesArray(value.getBytesList(fieldIndex));
@Override public List<String> getStringList(String columnName) { return getCurrentRowAsStruct().getStringList(columnName); }
@Override public List<String> getStringList(int columnIndex) { return getCurrentRowAsStruct().getStringList(columnIndex); }
return GSON.toJson(currentRow.getDoubleArray(columnName)); case STRING: return GSON.toJson(currentRow.getStringList(columnName)); case BYTES: return GSON.toJson(
builder.set(field, nullValue ? null : row.getStringList(fieldName)); } else if (spannerType.equals("ARRAY<TIMESTAMP>")) { if (nullValue) {
return Value.int64Array(value.getLongArray(fieldIndex)); case STRING: return Value.stringArray(value.getStringList(fieldIndex)); case BYTES: return Value.bytesArray(value.getBytesList(fieldIndex));