Skip to content
Advertisement

Stop BigQuery from truncating output

I need to export a query into a json using the bq cli (on bash b.t.w.)

I am using this command:

bq --format=json query --use_legacy_sql=false 'SELECT text FROM `<project>.<dataset>.<table>`' | jq -c '.[].text'

This works just fine at giving me an output:

"Lorem ipsum dolor sit amet, consectetur adipiscing elit."
"Mauris vehicula mauris eu tortor blandit pulvinar."
"Cras semper lacus vitae tellus laoreet porttitor."
"Duis fringilla dolor ut justo porttitor faucibus."
"etc."

Just like I want. The only problem is that this stops at around 100 lines, and I want all of the data in the sql table, not just a sample size. I know how to do this through the Google Cloud console – simply being a matter of executing the query and clicking export – but I cannot figure out how to do it through the cli as necessary.

I imagine this is something that people would like to do pretty often, so if you have any information it would be of extraordinarily great use to me, and I’m sure anyone else that sees this tread.

Thank you

Advertisement

Answer

per Command-line tool reference

--max_rows or -n
An integer specifying the number of rows to return in the query results. 
The default value is 100.
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement