I am executing BigQuery command via api in CloudShell for extracting view definitions using shell script as shown below
for file_name in $(cat view_list.txt)
do
file_name=${file_name/.sql/}
echo "$file_name"
query_output=`bq query --batch --use_legacy_sql=false --quiet --format=sparse \
"
SELECT view_definition
FROM projectid.datasetid.INFORMATION_SCHEMA.VIEWS
where table_name = '$file_name'
" | awk '{if(NR>2)print}'`
echo "$query_output" >> "./views/$file_name".sql
done
Some of the views are getting extracted in full and some are just getting truncated with ellipsis showing up. Out of just sample 10 that I ran 5 of them are in this manner. Can someone help me where I am going wrong with this?