-
Notifications
You must be signed in to change notification settings - Fork 121
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
Schema not propagated when querying for array of structs #3389
Comments
Hi @FredrikMeyer , Schemas are stored in TableResult and not necessarily FieldValueList. FieldValueList is used for table rows and the schema is not assessable. The schema in FieldValueList is for indexing by field name. To get the schema for your table, you can simply:
I hope this helps, |
Thanks for the answer @PhongChuong My main problem is that since the schema is not in the FieldValueList, I cannot get the fields by name. So now my code looks like this: private fun periodeFromFieldValue(periodeRecord: FieldValue) = Periode(
// cannot do recordValue.get("fraDato") because schema is not propagated
fraDato = LocalDate.parse(periodeRecord.recordValue[0].stringValue),
tilDato = LocalDate.parse(periodeRecord.recordValue[1].stringValue),
) Which seems to rely on the order the fields appear - which seem to coincide with the order they were defined in the table schema (by accident or by construction?). |
The field will appear as they are defined in the table schema by construction. If you want, it is possible to provide the schema manually providing the schema by creating FieldValueList. However, it's not pretty and probably not worth the effort. |
Hi, sorry for the late reply, but is there really a method |
Environment details
implementation("com.google.cloud:google-cloud-bigquery:2.41.0")
Steps to reproduce
Code example
Reproduced here: https://github.com/FredrikMeyer/bigquery-bug/blob/main/src/test/java/no/fredrikmeyer/MainTest.java
Any additional information below
When having an array of structs, the schema does not seem to be propagated to the fields. Thanks!
The text was updated successfully, but these errors were encountered: