@Override public double getDouble(String columnName) { return getCurrentRowAsStruct().getDouble(columnName); }
return Value.bytes(value.getBytes(fieldIndex)); case FLOAT64: return Value.float64(value.getDouble(fieldIndex)); case DATE: return Value.date(value.getDate(fieldIndex));
break; case DOUBLE: builder.set(field, nullValue ? null : row.getDouble(fieldName)); break; case BYTES:
@Override public double getDouble(int columnIndex) { return getCurrentRowAsStruct().getDouble(columnIndex); }
return Value.bytes(value.getBytes(fieldIndex)); case FLOAT64: return Value.float64(value.getDouble(fieldIndex)); case DATE: return Value.date(value.getDate(fieldIndex));
@Test public void negativeInfinity() { Struct row = execute(Statement.newBuilder("SELECT IEEE_DIVIDE(-1, 0)"), Type.float64()); assertThat(row.getDouble(0)).isNegativeInfinity(); }
@Test public void positiveInfinity() { Struct row = execute(Statement.newBuilder("SELECT IEEE_DIVIDE(1, 0)"), Type.float64()); assertThat(row.getDouble(0)).isPositiveInfinity(); }
@Test public void notANumber() { Struct row = execute(Statement.newBuilder("SELECT IEEE_DIVIDE(0, 0)"), Type.float64()); assertThat(row.getDouble(0)).isNaN(); }
@Test public void bindFloat64() { Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to(2.0), Type.float64()); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDouble(0)).isWithin(0.0).of(2.0); }
@Test public void writeFloat64NonNumbers() { write(baseInsert().set("Float64Value").to(Double.NEGATIVE_INFINITY).build()); Struct row = readLastRow("Float64Value"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDouble(0)).isNegativeInfinity(); write(baseInsert().set("Float64Value").to(Double.POSITIVE_INFINITY).build()); row = readLastRow("Float64Value"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDouble(0)).isPositiveInfinity(); write(baseInsert().set("Float64Value").to(Double.NaN).build()); row = readLastRow("Float64Value"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDouble(0)).isNaN(); }
@Test public void writeFloat64() { write(baseInsert().set("Float64Value").to(2.0).build()); Struct row = readLastRow("Float64Value"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDouble(0)).isWithin(0.0).of(2.0); }
private void assertRow(Struct actualRow, JSONArray expectedRow) throws Exception { assertThat(actualRow.getColumnCount()).isEqualTo(expectedRow.length()); for (int i = 0; i < expectedRow.length(); i++) { switch (actualRow.getColumnType(i).getCode()) { case BOOL: assertThat(actualRow.getBoolean(i)).isEqualTo(expectedRow.getBoolean(i)); break; case STRING: assertThat(actualRow.getString(i)).isEqualTo(expectedRow.getString(i)); break; case INT64: assertThat(actualRow.getLong(i)).isEqualTo(expectedRow.getLong(i)); break; case FLOAT64: assertThat(actualRow.getDouble(i)).isEqualTo(expectedRow.getDouble(i)); break; case BYTES: assertThat(actualRow.getBytes(i)) .isEqualTo(ByteArray.fromBase64(expectedRow.getString(i))); break; case ARRAY: Type elementType = actualRow.getColumnType(i).getArrayElementType(); assertArray(getRawList(actualRow, i, elementType), expectedRow.getJSONArray(i)); break; default: Assert.fail("Unexpected type code:" + actualRow.getColumnType(i).getCode()); } } }
@Override public double getDouble(int columnIndex) { return getCurrentRowAsStruct().getDouble(columnIndex); }
@Override public double getDouble(String columnName) { return getCurrentRowAsStruct().getDouble(columnName); }
case FLOAT64: return nullSafeColumnParser( ((currentRow, columnName) -> Double.toString(currentRow.getDouble(columnName)))); case STRING: return nullSafeColumnParser(Struct::getString);