-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BigQuery Java API: NPE on com.google.cloud.bigquery.StandardTableDefinition.fromPb(StandardTableDefinition.java:298) #296
Comments
@chetanmeda I tested it many times but still not able to reproduce that error, |
@pmakani A table created with the API google-api-services-bigquery does not define partition type as an Enum. And the TimePartitioning Type need not be "DAY" and can be null as well. Try creating a table with the below code. Table tablePb = new Table();
bigquery above is an instance of com.google.api.services.bigquery.Bigquery. Table created using code like above ( timePartitioning.setType(null) ) is a valid partitioned table and works perfectly. But the new API has Timepartitioning.Type as Enum which causes the exception. As per the below Type is a enum java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TimePartitioning.java Line 43 in b539f95
So we have to change the below line java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TimePartitioning.java Line 145 in b539f95
to newBuilder(Type.valueOf(firstNonNull(partitioningPb.getType(),Type.DAY))
|
So, this is an odd behavior, and the backend is allowing nulls but probably should not. I've filed an internal issue (155198865) to see if this can be corrected or documented in the backend. The important thing to note here is that the behavior (setting a null partitioning type) is undefined, and shouldn't be used. We can consider allowing it through the manual library, but I'd like to confirm what the intent is internally (document or restrict) for unset types before we address this in this library. |
@shollyman The backend should allow nulls because setting TimePartitioning type as "DAY" is not mandatory requirement. So In the above table creation code, omitting The new library can expect it to be mandatorily assigned, but cannot always expect a value to be returned for TimePartitioning.Type because most of the tables created using java library did not need it. More of what the client java library is expecting as mandatory behaviour should become non-mandatory behaviour. This issue is causing the new client library to be unusable for us and we have to revert to using google-api-services-bigquery directly. Can this change for TimePartitioning.Type to be able to accept null Types while reading a Table be done so that we can continue using google-cloud-bigquery. |
@pmakani - Thanks for the PR , Let me know it will get merged and when will we get the latest jar out if it |
@stephaniewang526 - Any idea when we can expect the latest jar ? https://repo.maven.apache.org/maven2/com/google/cloud/google-cloud-bigquery/1.111.1/ |
It should be release on Monday, 5/4. |
@stephaniewang526 - Thanks for the update |
@stephaniewang526 - I could see latest jars https://repo.maven.apache.org/maven2/com/google/cloud/google-cloud-bigquery/1.111.3/ |
https://repo1.maven.org/maven2/com/google/cloud/google-cloud-bigquery/ please find the latest jar, 1.111.3 here. |
Environment details
General, Core, and Other are also allowed as types
com.google.cloud
google-cloud-bigquery
1.110.0
Steps to reproduce
NOT ABLE TO REPRODUCE
Code example
Stack trace
Any additional information below
This issue occurs on a few tables in Prod which I am not able to replicate in Dev.
The rpc call has the partition type as null but the TimePartitioning object in the response pb is not null which is leading to an NPE at this point.
java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/StandardTableDefinition.java
Line 276 in b539f95
The text was updated successfully, but these errors were encountered: