The simplest tool to manage Bigquery's views.
go install github.com/k-kawa/bqv
Or you can use bqv
as a Docker image, which is available at kkawa/bqv
Make a directory based on the names of the dataset and the view that you want to create.
mkdir -p your_dataset/your_view
Make an query.sql
file in it, which is going to use to create the view.
cat <<EOF > your_dataset/your_view/query.sql
SELECT 1 AS one
EOF
List the view names which are going to manage with bqv list
command.
bqv list
your_dataset.your_view
Make the view into the GCP project named your_project
with bqv apply
command.
bqv apply --projecID=your_project
INFO[0001] Creating view(your_dataset.your_view)
bra bra bra ....
Destroy all the views in the GCP project with bqv destroy
command.
bqv destroy --projectID=your_project
INFO[0001] Deleting view your_dataset.your_view
You can use the query.sql
file as a template and replace the placeholders in it when you run bqv apply
.
# Create another directory
mkdir -p your_dataset/your_new_view
# Create the new query.sql following the Golang's template syntax.
cat <<EOF > your_dataset/your_new_view/query.sql
SELECT "{{.data}}" AS data
EOF
# Prepare a JSON file the keys and values in which are going to fill the query.sql
cat <<EOF > parameters.json
{"data": "data"}
EOF
# Run bqv apply with the parameters.json
bqv apply --paramFile=parameters.json