{"id":15866352,"url":"https://github.com/squidmin/bigquery-labs","last_synced_at":"2025-06-12T13:07:51.539Z","repository":{"id":157749581,"uuid":"622626193","full_name":"squidmin/bigquery-labs","owner":"squidmin","description":"GCP BigQuery CLI","archived":false,"fork":false,"pushed_at":"2023-06-04T01:53:44.000Z","size":176,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T21:21:04.514Z","etag":null,"topics":["bigquery","gcp","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/squidmin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-02T16:59:31.000Z","updated_at":"2023-04-03T01:44:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"e9ff15c3-af8a-462b-be22-d451e85409c1","html_url":"https://github.com/squidmin/bigquery-labs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/squidmin/bigquery-labs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squidmin%2Fbigquery-labs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squidmin%2Fbigquery-labs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squidmin%2Fbigquery-labs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squidmin%2Fbigquery-labs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/squidmin","download_url":"https://codeload.github.com/squidmin/bigquery-labs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squidmin%2Fbigquery-labs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259470949,"owners_count":22862998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bigquery","gcp","java"],"created_at":"2024-10-05T23:20:26.216Z","updated_at":"2025-06-12T13:07:51.518Z","avatar_url":"https://github.com/squidmin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bigquery-labs\n\nGCP BigQuery labs using the Java SDK.\n\n\n\u003cdetails\u003e\n\u003csummary\u003eAbout\u003c/summary\u003e\n\nMade with:\n- **Adoptium Temurin OpenJDK 11.0.17**\n- **Spring Boot v2.4.3**\n- **Apache Maven 3.8.7**\n- **IntelliJ IDEA 2023.1 (Ultimate Edition)**\n- **GoLand 2023.1 (Ultimate Edition)**\n- **PyCharm 2023.1 (Ultimate Edition)**\n\n\u003c/details\u003e\n\n\n---\n\n\n## Install \u0026 build\n\n\u003cdetails\u003e\n\u003csummary\u003eDownload, install, and initialize the gcloud SDK on your local machine\u003c/summary\u003e\n\nRefer to the \u003ca href=\"https://cloud.google.com/sdk/docs/install#other_installation_options\"\u003e`gcloud` CLI documentation\u003c/a\u003e to complete this step.\n\nInstall the `gcloud` SDK to the user's home directory (e.g., `/Users/USERNAME/google-cloud-sdk`). \n\nWhen it's finished installing, add the `gcloud` executable to your system's `$PATH` and run the command:\n\n```shell\ngcloud init\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003egcloud CLI: Generate an Application Default Credentials (ADC) access token\u003c/summary\u003e\n\nIf you're running the application locally, you can use the following command to generate an access token:\n\n```shell\nexport GCP_ADC_ACCESS_TOKEN=\"$(gcloud auth application-default print-access-token)\"\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003egcloud CLI: Generate a GCP service account access token\u003c/summary\u003e\n\nRun this command to generate an access token for a specific GCP service account:\n\n```shell\nexport GCP_SA_ACCESS_TOKEN=$(gcloud auth print-access-token --impersonate-service-account='GCP_SA_EMAIL_ADDRESS')\n```\n\n**Replace the following**:\n- `GCP_SA_EMAIL_ADDRESS`: the email address of the service account to impersonate.\n\nExample:\n\n```shell\nexport GCP_SA_ACCESS_TOKEN=$(gcloud auth print-access-token --impersonate-service-account='sa-developer@your-sa-name.iam.gserviceaccount.com')\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eCreate and store a service account key\u003c/summary\u003e\n\nThis section refers to usage of a GCP service account key (.json) file stored on your local file system.\n\nTo map a local `gcloud` installation to a volume on a container instance running the application, include the `-v` parameter in the `docker run` command used to start a container instance, as described below. \n\n### macOS\n\nAssuming the user's service account key file is stored in the same directory as their local `gcloud` installation:\n\n`/Users/USERNAME/.config/gcloud`\n\n```shell\nexport LOCAL_GCLOUD_AUTH_DIRECTORY=$HOME/.config/gcloud\n```\n\nand the target volume on the container instance is: \n\n`/root/.config/gcloud`\n\n```shell\nexport CONTAINER_GCLOUD_AUTH_DIRECTORY=/root/.config/gcloud\n```\n\nthe command to run the container instance would be:\n\n```shell\ndocker run --rm -it \\\n  -e GCP_SA_KEY_PATH=$GCP_SA_KEY_PATH \\\n  -e GCP_ADC_ACCESS_TOKEN=$GCP_ADC_ACCESS_TOKEN \\\n  -e GCP_SA_ACCESS_TOKEN=$GCP_SA_ACCESS_TOKEN \\\n  -e GCP_DEFAULT_USER_PROJECT_ID=$GCP_DEFAULT_USER_PROJECT_ID \\\n  -e GCP_DEFAULT_USER_DATASET=$GCP_DEFAULT_USER_DATASET \\\n  -e GCP_DEFAULT_USER_TABLE=$GCP_DEFAULT_USER_TABLE \\\n  -e GCP_SA_PROJECT_ID=$GCP_SA_PROJECT_ID \\\n  -e GCP_SA_DATASET=$GCP_SA_DATASET \\\n  -e GCP_SA_TABLE=$GCP_SA_TABLE \\\n  -v ${LOCAL_GCLOUD_AUTH_DIRECTORY}:${CONTAINER_GCLOUD_AUTH_DIRECTORY} \\\n  -v ${LOCAL_MAVEN_REPOSITORY}:${CONTAINER_MAVEN_REPOSITORY} \\\n  bigquery-labs\n```\n\n**Replace the following** in the path to the `gcloud` directory:\n\n- `USERNAME`: the current OS user's username\n\nso that the path to the service account key file is correct, e.g.:\n\n`/Users/squidmin/.config/gcloud/sa-private-key.json`\n\nRead \u003ca href=\"https://cloud.google.com/iam/docs/keys-create-delete#iam-service-account-keys-create-gcloud\"\u003ehere\u003c/a\u003e for more information about creating service account keys.\n\nRead \u003ca href=\"\"\u003ehere\u003c/a\u003e for more information about run config CLI arguments.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eAdd the Maven wrapper\u003c/summary\u003e\n\nEnsure that Maven is already installed on the machine that will run the container.\n\nIn the root of this project, run the command:\n\n```shell\nmvn wrapper:wrapper\n```\n\nRead \u003ca href=\"https://maven.apache.org/install.html\"\u003ehere\u003c/a\u003e for more information about installing Maven.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eBuild a JAR\u003c/summary\u003e\n\n```shell\n./mvnw clean package -P integration \\\n  -DGCP_SA_KEY_PATH=$GCP_SA_KEY_PATH \\\n  -DGCP_ADC_ACCESS_TOKEN=$GCP_ADC_ACCESS_TOKEN \\\n  -DGCP_SA_ACCESS_TOKEN=$GCP_SA_ACCESS_TOKEN \\\n  -DGCP_DEFAULT_USER_PROJECT_ID=$GCP_DEFAULT_USER_PROJECT_ID \\\n  -DGCP_DEFAULT_USER_DATASET=$GCP_DEFAULT_USER_DATASET \\\n  -DGCP_DEFAULT_USER_TABLE=$GCP_DEFAULT_USER_TABLE \\\n  -DGCP_SA_PROJECT_ID=$GCP_SA_PROJECT_ID \\\n  -DGCP_SA_DATASET=$GCP_SA_DATASET \\\n  -DGCP_SA_TABLE=$GCP_SA_TABLE\n```\n\nOr use `mvn clean install`:\n\n```shell\n./mvnw clean install -P integration \\\n  -DGCP_SA_KEY_PATH=$HOME/.config/gcloud \\\n  -DGCP_ADC_ACCESS_TOKEN=\"$(gcloud auth application-default print-access-token)\" \\\n  -DGCP_SA_ACCESS_TOKEN=placeholder \\\n  -DGCP_DEFAULT_USER_PROJECT_ID=lofty-root-378503 \\\n  -DGCP_DEFAULT_USER_DATASET=test_dataset_integration \\\n  -DGCP_DEFAULT_USER_TABLE=test_table_integration \\\n  -DGCP_SA_PROJECT_ID=placeholder \\\n  -DGCP_SA_DATASET=placeholder \\\n  -DGCP_SA_TABLE=placeholder\n```\n\nRead \u003ca href=\"\"\u003ehere\u003c/a\u003e for more information about run config CLI arguments.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eBuild a container image\u003c/summary\u003e\n\n```shell\ndocker build \\\n  --build-arg GCP_SA_KEY_PATH=${GCP_SA_KEY_PATH} \\\n  --build-arg GCP_DEFAULT_USER_PROJECT_ID=${GCP_DEFAULT_USER_PROJECT_ID} \\\n  --build-arg GCP_DEFAULT_USER_DATASET=${GCP_DEFAULT_USER_DATASET} \\\n  --build-arg GCP_DEFAULT_USER_TABLE=${GCP_DEFAULT_USER_TABLE} \\\n  --build-arg GCP_SA_PROJECT_ID=${GCP_SA_PROJECT_ID} \\\n  --build-arg GCP_SA_DATASET=${GCP_SA_DATASET} \\\n  --build-arg GCP_SA_TABLE=${GCP_SA_TABLE} \\\n  -t bigquery-labs .\n```\n\nRead \u003ca href=\"\"\u003ehere\u003c/a\u003e for more information about run config CLI arguments.\n\n\u003c/details\u003e\n\n\n---\n\n\n## Run the application\n\n\n### 1a. Prepare the host machine environment\n\n\u003cdetails\u003e\n\u003csummary\u003eExpand\u003c/summary\u003e\n\nUntil the main application entrypoint is developed, run the application's functionality via the `mvn test` interface.\n\nPass required environment variables on your local system to the VM options, as shown in the `createTableWithCustomSchema` example below:\n\n```shell\n./mvnw \\\n  -Dtest=BigQueryAdminClientIntegrationTest#listDatasets \\\n  test -P integration \\\n  -DGCP_SA_KEY_PATH=$GCP_SA_KEY_PATH \\\n  -DGCP_ADC_ACCESS_TOKEN=$GCP_ADC_ACCESS_TOKEN \\\n  -DGCP_SA_ACCESS_TOKEN=$GCP_SA_ACCESS_TOKEN \\\n  -DGCP_DEFAULT_USER_PROJECT_ID=$GCP_DEFAULT_USER_PROJECT_ID \\\n  -DGCP_DEFAULT_USER_DATASET=$GCP_DEFAULT_USER_DATASET \\\n  -DGCP_DEFAULT_USER_TABLE=$GCP_DEFAULT_USER_TABLE\n```\n\n\u003c/details\u003e\n\n\n### 1b. Prepare the container environment\n\n\u003cdetails\u003e\n\u003csummary\u003eExpand\u003c/summary\u003e\n\n### Environment variables\n\nThe `GCP_SA_KEY_PATH` environment variable is used to store the path to the user's GCP service account key file.\nThe user's service account key file is mapped to the `/root/.config/gcloud` directory on the container instance.\n\n```shell\nexport GCP_SA_KEY_PATH=/root/.config/gcloud/sa-private-key.json\n```\n\nThe `GCP_ADC_ACCESS_TOKEN` environment variable is used to store an OAuth2 access token for reaching BigQuery RESTful services _using Application Default Credentials_ (ADC).\n\n```shell\nexport GCP_ADC_ACCESS_TOKEN=$(gcloud auth application-default print-access-token)\n```\n\nThe `GCP_SA_ACCESS_TOKEN` environment variable is used to store an OAuth2 access token for reaching BigQuery RESTful services _as a specific service account_.\n\n```shell\nexport GCP_SA_ACCESS_TOKEN=$(gcloud auth print-access-token --impersonate-service-account=\"sa-developer@your-sa-name.iam.gserviceaccount.com\")\n```\n\n### Utility script (WIP)\n\nThe `run.sh` script at the root level of the project will set required environment variables automatically.\n\nIt accepts short and long arguments for each environment variable.\n\n\u003c/details\u003e\n\n\n### 2. Run an interactive container instance\n\n\u003cdetails\u003e\n\u003csummary\u003eExpand\u003c/summary\u003e\n\n### `docker run`\n\n```shell\ndocker run --rm -it \\\n  -e GCP_SA_KEY_PATH=$GCP_SA_KEY_PATH \\\n  -e GCP_ADC_ACCESS_TOKEN=$GCP_ADC_ACCESS_TOKEN \\\n  -e GCP_SA_ACCESS_TOKEN=$GCP_SA_ACCESS_TOKEN \\\n  -e GCP_DEFAULT_USER_PROJECT_ID=$GCP_DEFAULT_USER_PROJECT_ID \\\n  -e GCP_DEFAULT_USER_DATASET=$GCP_DEFAULT_USER_DATASET \\\n  -e GCP_DEFAULT_USER_TABLE=$GCP_DEFAULT_USER_TABLE \\\n  -e GCP_SA_PROJECT_ID=$GCP_SA_PROJECT_ID \\\n  -e GCP_SA_DATASET=$GCP_SA_DATASET \\\n  -e GCP_SA_TABLE=$GCP_SA_TABLE \\\n  -v ${LOCAL_GCLOUD_AUTH_DIRECTORY}:${CONTAINER_GCLOUD_AUTH_DIRECTORY} \\\n  -v ${LOCAL_MAVEN_REPOSITORY}:${CONTAINER_MAVEN_REPOSITORY} \\\n  bigquery-labs\n```\n\nRead \u003ca href=\"\"\u003ehere\u003c/a\u003e for more information about run config CLI arguments.\n\n---\n\n### `./run.sh` utility script\n\n```shell\n./run.sh \\\n  -dpid $GCP_DEFAULT_USER_PROJECT_ID \\\n  -sakp $HOME/.config/gcloud/sa-private-key.json \\\n  -saat access_token_placeholder \\\n  -adcat $(gcloud auth application-default print-access-token)\n```\n\nOr use long arguments:\n\n```shell\n./run.sh \\\n  --GCP_DEFAULT_USER_PROJECT_ID $GCP_DEFAULT_USER_PROJECT_ID \\\n  --GCP_SA_KEY_PATH $HOME/.config/gcloud/sa-private-key.json \\\n  --GCP_SA_ACCESS_TOKEN access_token_placeholder \\\n  --GCP_ADC_ACCESS_TOKEN $(gcloud auth application-default print-access-token)\n```\n\n### `run.sh` options\n\n\u003cdetails\u003e\n\u003csummary\u003eExpand\u003c/summary\u003e\n\n`run.sh` implements the following options:\n\n- `--default`: Start the application on the user's host system with default run environment settings.\u003cbr\u003e\n\n  \u003cdetails\u003e\n  \u003csummary\u003eExample\u003c/summary\u003e\n\n  ```shell\n  ./run.sh --default\n  ```\n\n  \u003c/details\u003e\n\n- `-ci`, `--container-instance`: Run a container instance pointing to the root directory of the application.\n\n  \u003cdetails\u003e\n  \u003csummary\u003eExample\u003c/summary\u003e\n\n  ```shell\n  ./run.sh --container-instance\n  ```\n\n  \u003c/details\u003e\n\n- `-nci`, `--no-container-instance`: Build and run the application without starting a container instance.\n\n  \u003cdetails\u003e\n  \u003csummary\u003eExample\u003c/summary\u003e\n\n  ```shell\n  ./run.sh -nci\n  ```\n\n  \u003c/details\u003e\n\n- `-i GCP_SA_EMAIL_ADDRESS`, `--impersonate GCP_SA_EMAIL_ADDRESS`: Impersonate a GCP service account.\n\n  Replace `GCP_SA_EMAIL_ADDRESS` with the email address of the service account to impersonate.\n\n  \u003cdetails\u003e\n  \u003csummary\u003eExample\u003c/summary\u003e\n\n  ```shell\n  ./run.sh --default -ci --impersonate-service-account GCP_SA_EMAIL_ADDRESS\n  ```\n\n  **Replace the following**:\n  - `GCP_SA_EMAIL_ADDRESS`: the impersonated service account's email address.\n\n  \u003c/details\u003e\n\n\u003c/details\u003e\n\n\n### Other examples\n\n\u003cdetails\u003e\n\u003csummary\u003eBuild JAR, build image, \u0026 start an interactive container instance with default run environment settings\u003c/summary\u003e\n\n```shell\n./run.sh --default --container-instance\n```\n\n```shell\n./run.sh --default -ci\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eBuild and run JAR with default run environment settings\u003c/summary\u003e\n\n```shell\n./run.sh --default\n```\n\n```shell\n./run.sh --default --no-container-instance\n```\n\n```shell\n./run.sh --default -nci\n```\n\n\u003c/details\u003e\n\n\n\u003c/details\u003e\n\n\n### 3. Run the JAR\n\n\u003e Note: This section currently is only used for testing the main application entrypoint.\n\u003e\n\u003e This project currently invokes the BigQuery Java SDK (and later the BigQuery RESTful services) via the `mvn test` interface. Use that for now.\n\u003e \n\u003e _**Refer to**_: \u003ca href=\"https://github.com/squidmin/bigquery-labs/blob/main/src/test/README.md\"\u003e`/src/test` README.md\u003c/a\u003e.\n\n\u003cdetails\u003e\n\u003csummary\u003eUsing \"exec java\" command. Specify a profile.\u003c/summary\u003e\n\n```shell\nexec java -jar \\\n  -Dspring.profiles.active=$PROFILE \\\n  -DGCP_SA_KEY_PATH=$GCP_SA_KEY_PATH \\\n  -DGCP_ADC_ACCESS_TOKEN=$GCP_ADC_ACCESS_TOKEN \\\n  -DGCP_SA_ACCESS_TOKEN=$GCP_SA_ACCESS_TOKEN \\\n  -DGCP_DEFAULT_USER_PROJECT_ID=$GCP_DEFAULT_USER_PROJECT_ID \\\n  -DGCP_DEFAULT_USER_DATASET=\"test_dataset_integration\" \\\n  -DGCP_DEFAULT_USER_TABLE=\"test_table_integration_custom\" \\\n  ./target/bigquery-labs-0.0.1-SNAPSHOT.jar\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eWith Maven. Specify a profile.\u003c/summary\u003e\n\n```shell\nmvn spring-boot:run \\\n  -Dspring-boot.run.profiles=$PROFILE \\\n  -DGCP_SA_KEY_PATH=$GCP_SA_KEY_PATH \\\n  -DGCP_ADC_ACCESS_TOKEN=$GCP_ADC_ACCESS_TOKEN \\\n  -DGCP_SA_ACCESS_TOKEN=$GCP_SA_ACCESS_TOKEN \\\n  -DGCP_DEFAULT_USER_PROJECT_ID=$GCP_DEFAULT_USER_PROJECT_ID \\\n  -DGCP_DEFAULT_USER_DATASET=\"test_dataset_integration\" \\\n  -DGCP_DEFAULT_USER_TABLE=\"test_table_integration_custom\"\n```\n\n\u003c/details\u003e\n\n\n---\n\n\n## Table admin\n\n### `bq` CLI\n\n\u003cdetails\u003e\n\u003csummary\u003eList datasets\u003c/summary\u003e\n\n```shell\nbq ls --filter labels.key:value \\\n  --max_results INTEGER \\\n  --format=prettyjson \\\n  --project_id PROJECT_ID\n```\n\n**Replace the following**:\n- `key:value`: a label key and value, if applicable.\n- `INTEGER`: an integer representing the number of datasets to list.\n- `PROJECT_ID`: the name of the GCP project containing the datasets to list.\n\n**Examples**:\n\n```shell\nbq ls --format=pretty\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eCreate a dataset\u003c/summary\u003e\n\nRefer to the \u003ca href=\"https://cloud.google.com/bigquery/docs/datasets#create-dataset\"\u003eGCP documentation for creating datasets\u003c/a\u003e.\n\n**Examples**:\n\n```shell\nbq --location=us mk \\\n  --dataset \\\n  --default_partition_expiration=3600 \\\n  --default_table_expiration=3600 \\\n  --description=\"An example.\" \\\n  --label=test_label_1:test_value_1 \\\n  --label=test_label_2:test_value_2 \\\n  --max_time_travel_hours=168 \\\n  --storage_billing_model=LOGICAL \\\n  ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}\n```\n\nThe Cloud Key Management Service (KMS) key parameter (`KMS_KEY_NAME`) can be specified.\nThis parameter is used to pass the name of the default Cloud Key Management Service key used to protect newly created tables in this dataset.\nYou cannot create a Google-encrypted table in a dataset with this parameter set.\n\n```shell\nbq --location=us mk \\\n  --dataset \\\n  --default_kms_key=KMS_KEY_NAME \\\n  ... \\\n  ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eDelete a dataset\u003c/summary\u003e\n\nRefer to the \u003ca href=\"https://cloud.google.com/bigquery/docs/managing-datasets#delete_a_dataset\"\u003eGCP documentation for deleting a dataset\u003c/a\u003e.\n\n#### Examples:\n\nRemove all tables in the dataset (`-r` flag):\n\n```shell\nbq rm -r -f -d ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eCreate a table with a configured schema\u003c/summary\u003e\n\n**Create an empty table with an inline schema definition**\n\n```shell\nbq mk --table PROJECT_ID:DATASET.TABLE SCHEMA\n```\n\n**Replace the following**:\n- `PROJECT_ID`: the name of the GCP project to target.\n- `DATASET`: the name of the BigQuery dataset to target.\n- `TABLE`: the name of the BigQuery table to target.\n- `SCHEMA`: an inline schema definition.\n\nExample:\n\n```shell\nbq mk --table \\\n  ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}.test_table_name_lofty \\\n  id:STRING,creation_timestamp:DATETIME,last_update_timestamp:DATETIME,column_a:STRING,column_b:BOOL\n```\n\n### Specify the schema in a JSON schema file\n\nFor an example JSON schema file, refer to: `/schema/example.json`.\n\n**Create an empty table**\n\n```shell\nbq mk --table \\\n  PROJECT_ID:DATASET.TABLE \\\n  ./path/to/schema/file.json\n```\n\nExample:\n\n```shell\nbq mk --table \\\n  ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}.test_table_name_lofty \\\n  ./schema/example.json\n```\n\n**Create a table with CSV data**\n\n```shell\nbq --location=location load \\\n  --source_format=format \\\n  PROJECT_ID:DATASET.TABLE \\\n  ./path/to/data/file.csv \\\n  ./path/to/schema/file.json\n```\n\nExample:\n\n```shell\nbq --location=us load \\\n  --source_format=CSV \\\n  ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}.test_table_name_lofty \\\n  ./csv/example.csv \\\n  ./schema/example.json\n```\n\nRefer to the BigQuery documentation: \u003ca href=\"https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-csv#details_of_loading_csv_data\"\u003eDetails of loading CSV data\u003c/a\u003e.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eDelete a table\u003c/summary\u003e\n\n```shell\nbq rm --table ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}.test_table_name_lofty\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eShow table schema\u003c/summary\u003e\n\nExample:\n\n```shell\nbq show \\\n  --schema \\\n  --format=prettyjson \\\n  ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}.test_table_name_lofty\n```\n\nThe table schema can be written to a file:\n\n```shell\nbq show \\\n  --schema \\\n  --format=prettyjson \\\n  ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}.test_table_name_lofty \\ \u003e ./schema/example_show-write.json\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eModify table schemas\u003c/summary\u003e\n\n```shell\nbq update \\\n  ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}.test_table_name_lofty \\\n  ./schema/example_update.json\n```\n\nRefer to the \u003ca href=\"https://cloud.google.com/bigquery/docs/managing-table-schemas\"\u003eGCP documentation on modifying table schemas.\u003c/a\u003e.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eInsert data into a table\u003c/summary\u003e\n\n**Examples**:\n\nInsert for known values:\n\n```shell\nbq insert ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}.test_table_name_lofty ./json/example.json\n```\n\nSpecify a template suffix (`--template_suffix` or `-x`):\n\n```shell\nbq insert --ignore_unknown_values \\\n  --template_suffix=_insert \\\n  ${GCP_DEFAULT_USER_PROJECT_ID}:${GCP_DEFAULT_USER_DATASET}.test_table_name_lofty \\\n  ./json/example.json\n```\n\nRefer to the \u003ca href=\"\"\u003e`bq insert` documentation\u003c/a\u003e.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eRun an interactive query\u003c/summary\u003e\n\n```shell\nbq query \\\n  --use_legacy_sql=false \\\n  'query_string'\n```\n\nExample:\n\n```shell\nbq query \\\n  --use_legacy_sql=false \\\n  'SELECT\n    id, column_b\n  FROM\n    `lofty-root-378503.test_dataset_name_lofty.test_table_name_lofty`\n  LIMIT\n    3;'\n```\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquidmin%2Fbigquery-labs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquidmin%2Fbigquery-labs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquidmin%2Fbigquery-labs/lists"}