0

I want to fetch data from BigQuery and display it on website page ; however , I fetch the data using the code below ,

   Integer offset = this.getPage(page, size);
        String query =
                String.format("select * from `COLLECTION` where status = 'FAILED' LIMIT %s OFFSET %s ;", size.toString(), offset.toString());
        QueryJobConfiguration queryConfig =
                QueryJobConfiguration.newBuilder(query)
                        .build();

        TableResult queryResult = bigquery.query(queryConfig);
        Iterable<FieldValueList> queryValues = queryResult.getValues();

queryValues returns the column names in property(schema) and values in another property(No page schema) . which really hard to map between row's values and column enter image description here

I want to return the result like this :

"mobile_no": "011111111",
"amount": "55",
"days": "3",

to be able to construct Dto and return it in my api response

Omar Abo Elsoud
  • 154
  • 2
  • 12
  • Thanks man for your comment , but no it doesn't – Omar Abo Elsoud Jan 12 '22 at 18:14
  • 2
    Apologies, I'm a python guy so my answer doesn't translate plainly. Looks like other people on StackOverflow have opined on the topic before, and one suggestion was just to have the query output the JSON you're looking for: https://stackoverflow.com/questions/48873729/how-to-get-query-results-from-tableresult-in-json-using-bigquery-api – Mike Karp Jan 12 '22 at 20:01

0 Answers0