Reputation: 349
I'm getting the following error when trying to execute the bq query:
FATAL Flags parsing error: Unknown command line flag '-v'
The query is simple and I think the problem is inside the concat function, because I'm trying to concat a curl command and there I have a -v flag, the query is below:
select concat('curl -v https://api.com.br/push.json -H \"Content-Type: application/json\" -H \"x_application: WebApp\" -H -X POST -d \'{\"pushes\":[\''
,string_agg(to_json_string(t)),']}\'') as json
How can I escape the -v to not getting this error?
Thanks
Upvotes: 0
Views: 1209
Reputation: 11777
Try running this:
bq query "select concat('curl -v https://api.com.br/push.json -H \"Content-Type: application/json\" -H \"x_application: WebApp\" -H -X POST -d \'{\"pushes\":[\'',string_agg(to_json_string(t)),']}\'') as json"
In order to prevent bash interpretation from the string, maybe reading the query from a file might help as well. If your query is something like:
WITH data AS(
select [1, 2] AS t
)
select
concat('curl -v https://api.com.br/push.json -H \"Content-Type: application/json\" -H \"x_application: WebApp\" -H -X POST -d \'{\"pushes\":[\'',string_agg(to_json_string(t)),']}\'') as json
FROM
data
You could save it for instance in a file "query.sql" and then run the command:
cat query.sql | bq query --use_legacy_sql=False
Upvotes: 2