Skip to content

Commit

Permalink
fix: getDouble in read API path (#2919)
Browse files Browse the repository at this point in the history
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [X] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/java-bigquery/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [X] Ensure the tests and linter pass
- [X] Code coverage does not decrease (if any source code was changed)
- [X] Appropriate docs were updated (if necessary)

Fixes #2905 ☕️
  • Loading branch information
obada-ab authored Oct 3, 2023
1 parent 91b83db commit 436ee8e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ implementation 'com.google.cloud:google-cloud-bigquery'
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-bigquery:2.33.0'
implementation 'com.google.cloud:google-cloud-bigquery:2.33.1'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.33.0"
libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.33.1"
```
<!-- {x-version-update-end} -->

Expand Down Expand Up @@ -351,7 +351,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquery/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigquery.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquery/2.33.0
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquery/2.33.1
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public double getDouble(String fieldName) throws SQLException {
throw new SQLException(String.format("Field %s not found", fieldName));
}
Object curVal = curRow.get(fieldName);
return curVal == null ? 0.0d : ((BigDecimal) curVal).doubleValue();
return curVal == null ? 0.0d : new BigDecimal(curVal.toString()).doubleValue();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3230,7 +3230,7 @@ public void testReadAPIIterationAndOrderAsync()
throws SQLException, ExecutionException,
InterruptedException { // use read API to read 300K records and check the order
String query =
"SELECT date, county, state_name, confirmed_cases, deaths FROM "
"SELECT date, county, state_name, confirmed_cases, deaths / 10 FROM "
+ TABLE_ID_LARGE.getTable()
+ " where date is not null and county is not null and state_name is not null order by confirmed_cases asc limit 300000";

Expand All @@ -3255,7 +3255,8 @@ public void testReadAPIIterationAndOrderAsync()
assertNotNull(rs.getString(1));
assertNotNull(rs.getString(2));
assertTrue(rs.getInt(3) >= 0);
assertTrue(rs.getInt(4) >= 0);
assertTrue(rs.getDouble(3) >= 0);
assertTrue(rs.getDouble(4) >= 0);

// check if the records are sorted
assertTrue(rs.getInt(3) >= lasConfirmedCases);
Expand Down

0 comments on commit 436ee8e

Please sign in to comment.