mini lab : BigQuery : 4 -lab solution (Skills Boost Arcade Trivia February 2025 Week 4)

Lab is working

Solution:

===============================================================

# Set the PROJECT_ID and REGION variables

export PROJECT_ID=$(gcloud config get-value project)
export REGION=$(gcloud compute project-info describe --format="value(commonInstanceMetadata.items[google-compute-default-region])")

#================================================================================
#copy cloud storage bucket name as per your lab.

export BUCKET_NAME=
#===============================================================
#Upload the csv data in your table from pre-created cloud storage bucket

bq load --source_format=CSV --autodetect products.products_information gs://$BUCKET_NAME/products.csv
#=========================================================================================================================

#Create a search index on the table_name table for all the columns.

bq query --use_legacy_sql=false "CREATE SEARCH INDEX IF NOT EXISTS products.p_i_search_index ON products.products_information (ALL COLUMNS);"
#==================================================================
#Run a query to search across all columns of the table_name table for the value 22 oz Water Bottle product and returns the #rows that contain this value using SEARCH method.

bq query --use_legacy_sql=false "SELECT * FROM products.products_information WHERE SEARCH(STRUCT(), '22 oz Water Bottle') = TRUE;"
#===================================================================================================================

#-------------------------------------------end of solution------------------------

0 0 192
0 REPLIES 0
Top Labels in this Space