Muestras de código de BigQuery
This page contains code samples for BigQuery. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.
Add a column using a query job
Add a new column to a BigQuery table while appending rows using a query job with an explicit destination table.
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
Clustered table
Load data from a CSV file on Cloud Storage to a clustered table.
View in documentation
Column-based time partitioning
Create a table that uses column-based time partitioning.
View in documentation
View in documentation
View in documentation
Create a client with a service account key file
Create a BigQuery client using a service account key file.
View in documentation
Create a client with application default credentials
Create a BigQuery client using application default credentials.
View in documentation
View in documentation
Create a dataset in BigQuery.
Sample demonstrating how to create a dataset in BigQuery. Give the dataset a unique name. Note, that the geographic location for the location can not be changed once the dataset is created.
View in documentation
Create a dataset with a customer-managed encryption key
The following example creates a dataset named `mydataset`, and also uses the `google_kms_crypto_key` and `google_kms_key_ring` resources to specify a Cloud Key Management Service key for the dataset. You must enable the Cloud Key Management Service API before running this example.
View in documentation
View in documentation
Create a table using a template
Create a table using the properties of one table (schema, partitioning, clustering) to create a new empty table with the same configuration.
View in documentation
View in documentation
View in documentation
Create an integer-range partitioned table
Create a new integer-range partitioned table in an existing dataset.
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
Download public table data to DataFrame
Use the BigQuery Storage API to speed up downloads of large tables to DataFrame.
Download public table data to DataFrame from the sandbox
Use the BigQuery Storage API to download query results to DataFrame.
Download query results to a GeoPandas GeoDataFrame
Download query results to a GeoPandas GeoDataFrame.
View in documentation
View in documentation
View in documentation
Export a table to a compressed file
Exports a table to a compressed file in a Cloud Storage bucket.
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
Load a DataFrame to BigQuery with pandas-gbq
Use the pandas-gbq package to load a DataFrame to BigQuery.
Load a JSON file
Loads a JSON file from Cloud Storage using an explicit schema.
View in documentation
Load a table in JSON format
Load a table with customer-managed encryption keys to Cloud Storage in JSON format.
View in documentation
View in documentation
Load an Avro file to replace a table
Load an Avro file from Cloud Storage, replacing existing table data.
View in documentation
Load data into a column-based time partitioning table
Load data into a table that uses column-based time partitioning.
View in documentation
Migration Guide: pandas-gbq
Samples for a guide for migrating from pandas-gbq to google-cloud-bigquery
View in documentation
Migration Guide: pandas-gbq
Samples for a guide for migrating from pandas-gbq to google-cloud-bigquery
View in documentation
View in documentation
View in documentation
View in documentation
View in documentation
Query Bigtable using a permanent table
Query data from a Bigtable instance by creating a permanent table.
View in documentation
Query Bigtable using a temporary table
Query data from a Bigtable instance by creating a temporary table.
View in documentation
Query Cloud Storage with a permanent table
Query data from a file on Cloud Storage by creating a permanent table.
View in documentation
Query Cloud Storage with a temporary table
Query data from a file on Cloud Storage by creating a temporary table.
View in documentation
View in documentation
Query Sheets with a permanent table
Query data from a Google Sheets file by creating a permanent table.
View in documentation
Query Sheets with a temporary table
Query data from a Google Sheets file by creating a temporary table.
View in documentation
View in documentation
- BigQuery API Client Libraries
- Getting started with authentication
- Query a public dataset with the BigQuery C# client library
- Query a public dataset with the BigQuery client libraries
- Query a public dataset with the BigQuery Go client library
- Query a public dataset with the BigQuery Java client library
- Query a public dataset with the BigQuery Node.js client library
- Query a public dataset with the BigQuery PHP client library
- Query a public dataset with the BigQuery Python client library
- Query a public dataset with the BigQuery Ruby client library
View in documentation
Relax a column in a load append job
Change a column from required to nullable in a load append job.
View in documentation