Hemant
Hemant

Reputation: 94

Updating a table description in BigQuery

I am trying to update the description of a table this way

bq update --description "${description_text}" ${project_id}:${dataset_name}.${table_name}

However when the description_text is multi line, it fails with the error Invalid header value My goal is to update the description a table with the SQL statement that it was created So am doing it programmatically to each time pick up a SQL file from a location, create the table and update the description from the contents of the SQL. That way, I know how that table was created

Upvotes: 0

Views: 529

Answers (2)

Matthew Housley
Matthew Housley

Reputation: 176

Certain installations of the bq command line tool are unable to process multiline inputs. Notably, the Google Cloud Shell is currently broken for me. (bq works fine in a fresh Compute Engine VM, and on my MacBook.)

You can work around this by using echo. For example

bq query 'select
5'

throws an error, but this works:

echo 'select
5' | bq query --nouse_legacy_sql

Upvotes: 0

Soumendra Mishra
Soumendra Mishra

Reputation: 3653

Please try this:

description_text="this is line one
this is line two
this is line three"

bq update --description "${description_text}" ${project_id}:${dataset_name}.${table_name}

Upvotes: 0

Related Questions