@Override public List<Double> getDoubleList(int columnIndex) { return getCurrentRowAsStruct().getDoubleList(columnIndex); }
@Override public List<Double> getDoubleList(String columnName) { return getCurrentRowAsStruct().getDoubleList(columnName); }
@Test public void nonNumberArray() { Struct row = execute( Statement.newBuilder( "SELECT [IEEE_DIVIDE(1, 0), IEEE_DIVIDE(-1, 0), IEEE_DIVIDE(0, 0)]"), Type.array(Type.float64())); assertThat(row.getDoubleList(0)).hasSize(3); assertThat(row.getDoubleList(0).get(0)).isPositiveInfinity(); assertThat(row.getDoubleList(0).get(1)).isNegativeInfinity(); assertThat(row.getDoubleList(0).get(2)).isNaN(); }
@Test public void bindFloat64ArrayEmpty() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toFloat64Array(Arrays.<Double>asList()), Type.array(Type.float64())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDoubleList(0)).containsExactly(); }
@Test public void writeFloat64ArrayEmpty() { write(baseInsert().set("Float64ArrayValue").toFloat64Array(new double[] {}).build()); Struct row = readLastRow("Float64ArrayValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDoubleList(0)).containsExactly(); }
@Test public void writeFloat64Array() { write( baseInsert() .set("Float64ArrayValue") .toFloat64Array(Arrays.asList(null, 1.0, 2.0)) .build()); Struct row = readLastRow("Float64ArrayValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDoubleList(0)).containsExactly(null, 1.0, 2.0).inOrder(); expectedException.expect(NullPointerException.class); row.getDoubleArray(0); }
@Test public void bindFloat64Array() { Struct row = execute( Statement.newBuilder("SELECT @v") .bind("v") .toFloat64Array( asList( null, 1.0, 2.0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN)), Type.array(Type.float64())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDoubleList(0)) .containsExactly( null, 1.0, 2.0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN) .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; }
@Override public List<Double> getDoubleList(String columnName) { return getCurrentRowAsStruct().getDoubleList(columnName); }
@Override public List<Double> getDoubleList(int columnIndex) { return getCurrentRowAsStruct().getDoubleList(columnIndex); }
case DOUBLE: builder.set(field, nullValue ? null : row.getDoubleList(fieldName)); break;