Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@google-cloud/bigquery
Advanced tools
@google-cloud/bigquery is a Node.js client library for Google BigQuery, a fully-managed, serverless data warehouse that enables scalable analysis over petabytes of data. This package allows you to interact with BigQuery to run queries, manage datasets, tables, and jobs, and perform data manipulations.
Running Queries
This feature allows you to run SQL queries against your BigQuery datasets. The code sample demonstrates how to run a simple query to select names and ages from a table where the age is greater than 30.
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
async function query() {
const query = 'SELECT name, age FROM `my-dataset.my-table` WHERE age > 30';
const options = { query: query, location: 'US' };
const [rows] = await bigquery.query(options);
console.log('Rows:', rows);
}
query();
Managing Datasets
This feature allows you to create and manage datasets in BigQuery. The code sample demonstrates how to create a new dataset named 'my_new_dataset'.
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
async function createDataset() {
const [dataset] = await bigquery.createDataset('my_new_dataset');
console.log(`Dataset ${dataset.id} created.`);
}
createDataset();
Managing Tables
This feature allows you to create and manage tables within datasets. The code sample demonstrates how to create a new table named 'my_new_table' within the 'my_new_dataset' dataset.
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
async function createTable() {
const dataset = bigquery.dataset('my_new_dataset');
const [table] = await dataset.createTable('my_new_table');
console.log(`Table ${table.id} created.`);
}
createTable();
Loading Data
This feature allows you to load data from various sources into BigQuery tables. The code sample demonstrates how to load data from a local CSV file into a table named 'my_new_table' within the 'my_new_dataset' dataset.
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
async function loadData() {
const dataset = bigquery.dataset('my_new_dataset');
const table = dataset.table('my_new_table');
const [job] = await table.load('local-file.csv');
console.log(`Job ${job.id} completed.`);
}
loadData();
The aws-sdk package is the official AWS SDK for JavaScript, which allows you to interact with various AWS services, including Amazon Redshift, a data warehouse service similar to Google BigQuery. While aws-sdk provides a broader range of functionalities across different AWS services, it can be used to perform similar data warehousing tasks as @google-cloud/bigquery.
The azure-sdk-for-js package is the official Azure SDK for JavaScript, which allows you to interact with various Azure services, including Azure Synapse Analytics, a data warehousing service similar to Google BigQuery. Like aws-sdk, azure-sdk-for-js offers a wide range of functionalities across different Azure services, including data warehousing capabilities.
The snowflake-sdk package is the official Node.js driver for Snowflake, a cloud-based data warehousing service. It provides functionalities to connect to Snowflake, run queries, and manage data, similar to what @google-cloud/bigquery offers for Google BigQuery.
Google BigQuery Client Library for Node.js
A comprehensive list of changes in each version may be found in the CHANGELOG.
Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.
Table of contents:
npm install @google-cloud/bigquery
// Imports the Google Cloud client library
const {BigQuery} = require('@google-cloud/bigquery');
async function createDataset() {
// Creates a client
const bigqueryClient = new BigQuery();
// Create the dataset
const [dataset] = await bigqueryClient.createDataset(datasetName);
console.log(`Dataset ${dataset.id} created.`);
}
createDataset();
Samples are in the samples/
directory. Each sample's README.md
has instructions for running its sample.
Sample | Source Code | Try it |
---|---|---|
Add Column Load Append | source code | |
Add Column Query Append | source code | |
Add Empty Column | source code | |
Auth View Tutorial | source code | |
Browse Table | source code | |
Cancel Job | source code | |
Client JSON Credentials | source code | |
Copy Table | source code | |
Copy Table Multiple Source | source code | |
Create Dataset | source code | |
Create Job | source code | |
Create Model | source code | |
Create Routine | source code | |
Create Routine DDL | source code | |
Create Table | source code | |
Create Table Clustered | source code | |
Create Table Column ACL | source code | |
Create Table Partitioned | source code | |
Create Table Range Partitioned | source code | |
Create View | source code | |
Ddl Create View | source code | |
Delete Dataset | source code | |
Delete Label Dataset | source code | |
Delete Label Table | source code | |
Delete Model | source code | |
Delete Routine | source code | |
Delete Table | source code | |
Extract Table Compressed | source code | |
Extract Table JSON | source code | |
Extract Table To GCS | source code | |
Get Dataset | source code | |
Get Dataset Labels | source code | |
Get Job | source code | |
BigQuery Get Model | source code | |
Get Routine | source code | |
BigQuery Get Table | source code | |
Get Table Labels | source code | |
Get View | source code | |
Insert Rows As Stream | source code | |
Inserting Data Types | source code | |
BigQuery Label Dataset | source code | |
Label Table | source code | |
List Datasets | source code | |
List Datasets By Label | source code | |
List Jobs | source code | |
BigQuery List Models | source code | |
BigQuery List Models Streaming | source code | |
List Routines | source code | |
List Tables | source code | |
Load CSV From GCS | source code | |
Load CSV From GCS Autodetect | source code | |
Load CSV From GCS Truncate | source code | |
Load JSON From GCS | source code | |
Load JSON From GCS Autodetect | source code | |
Load JSON From GCS Truncate | source code | |
Load Local File | source code | |
Load Orc From GCS Truncate | source code | |
Load Parquet From GCS Truncate | source code | |
Load Table Clustered | source code | |
Load Table GCS Avro | source code | |
Load Table GCS Avro Truncate | source code | |
Load Table GCSORC | source code | |
Load Table GCS Parquet | source code | |
Load Table Partitioned | source code | |
Load Table URI Firestore | source code | |
Nested Repeated Schema | source code | |
Query | source code | |
Query Batch | source code | |
Query Clustered Table | source code | |
Query Destination Table | source code | |
Query Disable Cache | source code | |
Query Dry Run | source code | |
Query External GCS Perm | source code | |
Query External GCS Temp | source code | |
Query Legacy | source code | |
Query Legacy Large Results | source code | |
Query Pagination | source code | |
Query Params Arrays | source code | |
Query Params Named | source code | |
Query Params Named Types | source code | |
Query Params Positional | source code | |
Query Params Positional Types | source code | |
Query Params Structs | source code | |
Query Params Timestamps | source code | |
Query Short Mode | source code | |
Query Stack Overflow | source code | |
Quickstart | source code | |
Relax Column | source code | |
Relax Column Load Append | source code | |
Relax Column Query Append | source code | |
Remove Table Clustering | source code | |
Set Client Endpoint | source code | |
Set User Agent | source code | |
Table Exists | source code | |
Undelete Table | source code | |
Update Dataset Access | source code | |
Update Dataset Description | source code | |
Update Dataset Expiration | source code | |
BigQuery Update Model | source code | |
Update Routine | source code | |
Update Table Column ACL | source code | |
Update Table Description | source code | |
Update Table Expiration | source code | |
Update View Query | source code |
The Google BigQuery Node.js Client API Reference documentation also contains samples.
Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js. If you are using an end-of-life version of Node.js, we recommend that you update as soon as possible to an actively supported LTS version.
Google's client libraries support legacy versions of Node.js runtimes on a best-efforts basis with the following warnings:
Client libraries targeting some end-of-life versions of Node.js are available, and
can be installed through npm dist-tags.
The dist-tags follow the naming convention legacy-(version)
.
For example, npm install @google-cloud/bigquery@legacy-8
installs client libraries
for versions compatible with Node.js 8.
This library follows Semantic Versioning.
This library is considered to be stable. The code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against stable libraries are addressed with the highest priority.
More Information: Google Cloud Platform Launch Stages
Contributions welcome! See the Contributing Guide.
Please note that this README.md
, the samples/README.md
,
and a variety of configuration files in this repository (including .nycrc
and tsconfig.json
)
are generated from a central template. To edit one of these files, make an edit
to its templates in
directory.
Apache Version 2.0
See LICENSE
FAQs
Google BigQuery Client Library for Node.js
The npm package @google-cloud/bigquery receives a total of 471,142 weekly downloads. As such, @google-cloud/bigquery popularity was classified as popular.
We found that @google-cloud/bigquery demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.