googleapis / googleapis/google-cloud-java

[java-bigquery] Schema not propagated when querying for array of structs

Ouverte
#12,155 6 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
api: bigquery priority: p3
Langage dominant
Java
Étoiles
2.1k
Forks
1.2k
Merge moyen
1 j 23 h
PR mergées (30 j)
154

Description

#### Environment details

1. Specify the API at the beginning of the title. For example, "BigQuery: ...").
```kotlin
implementation("com.google.cloud:google-cloud-bigquery:2.41.0")
```
2. OS type and version: MacOS
3. Java version: 21

#### Steps to reproduce

1. Create a table with a repeated struct schema.
2. Query the same table, try to access the nested record fields by name. This fails because no schema is attached.

#### Code example

Reproduced here: https://github.com/FredrikMeyer/bigquery-bug/blob/main/src/test/java/no/fredrikmeyer/MainTest.java

```java
var query = "select * from my_dataset.my_table";

QueryJobConfiguration queryJobConfiguration = QueryJobConfiguration.newBuilder(query).setUseLegacySql(false).build();

var res2 = bigQuery.query(queryJobConfiguration);

res2.iterateAll().forEach(r -> {
// Prints true
System.out.println(r.hasSchema());
// Prints false, even though the schema is defined above
System.out.println(r.get("arr").getRepeatedValue().getFirst().getRecordValue().hasSchema());
});
```

#### Any additional information below

When having an array of structs, the schema does not seem to be propagated to the fields. Thanks!

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.