Send feedback
Class BigQuery (5.6.0) Stay organized with collections
Save and categorize content based on your preferences.
Version 5.6.0 keyboard_arrow_down
In the following examples from this page and the other modules ( Dataset
, Table
, etc.), we are going to be using a dataset from [data.gov]( http://goo.gl/f2SXcb
) of higher education institutions.
We will create a table with the correct schema, import the public CSV file into that table, and query it for data.
[What is BigQuery?] https://cloud.google.com/bigquery/what-is-bigquery
Inheritance
common. Service
>
BigQuery
Package
@google-cloud/bigquery!
Constructors
(constructor)(options)
constructor
(
options
?:
BigQueryOptions
);
Constructs a new instance of the BigQuery
class
Parameter
Properties
createQueryStream
createQueryStream
:
(
options
?:
Query
|
string
)
=
>
ResourceStream<RowMetadata>
;
Property Value
getDatasetsStream
getDatasetsStream
:
(
options
?:
GetDatasetsOptions
)
=
>
ResourceStream<Dataset>
;
Property Value
getJobsStream
getJobsStream
:
(
options
?:
GetJobsOptions
)
=
>
ResourceStream<Job>
;
Property Value
location
Property Value
Methods
createDataset(id, options)
createDataset
(
id
:
string
,
options
?:
DatasetResource
)
:
Promise<DatasetResponse>
;
Parameters
Returns
createDataset(id, options, callback)
createDataset
(
id
:
string
,
options
:
DatasetResource
,
callback
:
DatasetCallback
)
:
void
;
Parameters
Returns
createDataset(id, callback)
createDataset
(
id
:
string
,
callback
:
DatasetCallback
)
:
void
;
Parameters
Returns
createJob(options)
createJob
(
options
:
JobOptions
)
:
Promise<JobResponse>
;
Parameter
Returns
createJob(options, callback)
createJob
(
options
:
JobOptions
,
callback
:
JobCallback
)
:
void
;
Parameters
Returns
createQueryJob(options)
createQueryJob
(
options
:
Query
|
string
)
:
Promise<JobResponse>
;
Parameter Name
Description
options
Query
| string
Returns
createQueryJob(options, callback)
createQueryJob
(
options
:
Query
|
string
,
callback
:
JobCallback
)
:
void
;
Parameters Name
Description
options
Query
| string
callback
JobCallback
Returns
dataset(id, options)
dataset
(
id
:
string
,
options
?:
DatasetOptions
)
:
Dataset
;
Create a reference to a dataset.
Parameters Name
Description
id
string
ID of the dataset.
options
DatasetOptions
Dataset options.
Returns
date(value)
date
(
value
:
BigQueryDateOptions
|
string
)
:
BigQueryDate
;
Parameter Name
Description
value
BigQueryDateOptions
| string
The date. If a string, this should be in the format the API describes: YYYY-[M]M-[D]D
. Otherwise, provide an object.
Returns
date(value)
static
date
(
value
:
BigQueryDateOptions
|
string
)
:
BigQueryDate
;
The DATE
type represents a logical calendar date, independent of time zone. It does not represent a specific 24-hour time period. Rather, a given DATE value represents a different 24-hour period when interpreted in different time zones, and may represent a shorter or longer day during Daylight Savings Time transitions.
Parameter Name
Description
value
BigQueryDateOptions
| string
The date. If a string, this should be in the format the API describes: YYYY-[M]M-[D]D
. Otherwise, provide an object.
Returns
datetime(value)
datetime
(
value
:
BigQueryDatetimeOptions
|
string
)
:
BigQueryDatetime
;
Parameter
Returns
datetime(value)
static
datetime
(
value
:
BigQueryDatetimeOptions
|
string
)
:
BigQueryDatetime
;
A DATETIME
data type represents a point in time. Unlike a TIMESTAMP
, this does not refer to an absolute instance in time. Instead, it is the civil time, or the time that a user would see on a watch or calendar.
BigQuery#datetime
Parameter Name
Description
value
BigQueryDatetimeOptions
| string
The time. If a string, this should be in the format the API describes: YYYY-[M]M-[D]D[ [H]H:[M]M:[S]S[.DDDDDD]]
. Otherwise, provide an object.
Returns
decodeIntegerValue_(value)
static
decodeIntegerValue_
(
value
:
IntegerTypeCastValue
)
:
number
;
Convert an INT64 value to Number.
Parameter Name
Description
value
IntegerTypeCastValue
The INT64 value to convert.
Returns
geography(value)
geography
(
value
:
string
)
:
Geography
;
Parameter
Returns
geography(value)
static
geography
(
value
:
string
)
:
Geography
;
A geography value represents a surface area on the Earth in Well-known Text (WKT) format.
BigQuery#geography
Parameter Name
Description
value
string
The geospatial data.
Returns
getDatasets(options)
getDatasets
(
options
?:
GetDatasetsOptions
)
:
Promise<DatasetsResponse>
;
Parameter
Returns
getDatasets(options, callback)
getDatasets
(
options
:
GetDatasetsOptions
,
callback
:
DatasetsCallback
)
:
void
;
Parameters
Returns
getDatasets(callback)
getDatasets
(
callback
:
DatasetsCallback
)
:
void
;
Parameter
Returns
getJobs(options)
getJobs
(
options
?:
GetJobsOptions
)
:
Promise<GetJobsResponse>
;
Parameter
Returns
getJobs(options, callback)
getJobs
(
options
:
GetJobsOptions
,
callback
:
GetJobsCallback
)
:
void
;
Parameters
Returns
getJobs(callback)
getJobs
(
callback
:
GetJobsCallback
)
:
void
;
Parameter
Returns
getTypeDescriptorFromProvidedType_(providedType)
static
getTypeDescriptorFromProvidedType_
(
providedType
:
string
|
ProvidedTypeStruct
|
ProvidedTypeArray
)
:
ValueType
;
Return a value's provided type.
Parameter
Returns Type
Description
ValueType
{string} The valid type provided.
getTypeDescriptorFromValue_(value)
static
getTypeDescriptorFromValue_
(
value
:
unknown
)
:
ValueType
;
Parameter
Returns Type
Description
ValueType
{string} The type detected from the value.
int(value, typeCastOptions)
int
(
value
:
string
|
number
|
IntegerTypeCastValue
,
typeCastOptions
?:
IntegerTypeCastOptions
)
:
BigQueryInt
;
Parameters
Returns
int(value, typeCastOptions)
static
int
(
value
:
string
|
number
|
IntegerTypeCastValue
,
typeCastOptions
?:
IntegerTypeCastOptions
)
:
BigQueryInt
;
A BigQueryInt wraps 'INT64' values. Can be used to maintain precision.
BigQuery#int
Parameters Name
Description
value
string | number | IntegerTypeCastValue
The INT64 value to convert.
typeCastOptions
IntegerTypeCastOptions
Configuration to convert value. Must provide an integerTypeCastFunction
to handle conversion.
Returns
job(id, options)
job
(
id
:
string
,
options
?:
JobOptions
)
:
Job
;
Create a reference to an existing job.
Parameters Name
Description
id
string
ID of the job.
options
JobOptions
Configuration object.
Returns
mergeSchemaWithRows_(schema, rows, wrapIntegers, selectedFields)
static
mergeSchemaWithRows_
(
schema
:
TableSchema
|
TableField
,
rows
:
TableRow
[],
wrapIntegers
:
boolean
|
IntegerTypeCastOptions
,
selectedFields
?:
string
[])
:
any
[];
Merge a rowset returned from the API with a table schema.
Parameters Name
Description
schema
TableSchema
| TableField
rows
TableRow
[]
wrapIntegers
boolean | IntegerTypeCastOptions
Wrap values of 'INT64' type in BigQueryInt
objects. If a boolean
, this will wrap values in BigQueryInt
objects. If an object
, this will return a value returned by wrapIntegers.integerTypeCastFunction
. Please see IntegerTypeCastOptions
for options descriptions.
selectedFields
string[]
List of fields to return. If unspecified, all fields are returned.
Returns Type
Description
any[]
{array} Fields using their matching names from the table's schema.
query(query, options)
query
(
query
:
string
,
options
?:
QueryOptions
)
:
Promise<QueryRowsResponse>
;
Parameters
Returns
query(query, options)
query
(
query
:
Query
,
options
?:
QueryOptions
)
:
Promise<SimpleQueryRowsResponse>
;
Parameters
Returns
query(query, options, callback)
query
(
query
:
string
,
options
:
QueryOptions
,
callback
?:
QueryRowsCallback
)
:
void
;
Parameters
Returns
query(query, options, callback)
query
(
query
:
Query
,
options
:
QueryOptions
,
callback
?:
SimpleQueryRowsCallback
)
:
void
;
Parameters Name
Description
query
Query
options
QueryOptions
callback
SimpleQueryRowsCallback
Returns
query(query, callback)
query
(
query
:
string
,
callback
?:
QueryRowsCallback
)
:
void
;
Parameters
Returns
query(query, callback)
query
(
query
:
Query
,
callback
?:
SimpleQueryRowsCallback
)
:
void
;
Parameters Name
Description
query
Query
callback
SimpleQueryRowsCallback
Returns
queryAsStream_(query, optionsOrCallback, cb)
queryAsStream_
(
query
:
Query
,
optionsOrCallback
?:
QueryStreamOptions
,
cb
?:
SimpleQueryRowsCallback
)
:
void
;
This method will be called by createQueryStream()
. It is required to properly set the autoPaginate
option value.
Parameters Name
Description
query
Query
optionsOrCallback
QueryStreamOptions
cb
SimpleQueryRowsCallback
Returns
time(value)
time
(
value
:
BigQueryTimeOptions
|
string
)
:
BigQueryTime
;
Parameter
Returns
time(value)
static
time
(
value
:
BigQueryTimeOptions
|
string
)
:
BigQueryTime
;
A TIME
data type represents a time, independent of a specific date.
BigQuery#time
Parameter Name
Description
value
BigQueryTimeOptions
| string
The time. If a string, this should be in the format the API describes: [H]H:[M]M:[S]S[.DDDDDD]
. Otherwise, provide an object.
Returns
timestamp(value)
timestamp
(
value
:
Date
|
string
)
:
BigQueryTimestamp
;
Parameter Name
Description
value
Date
| string
Returns
timestamp(value)
static
timestamp
(
value
:
Date
|
string
)
:
BigQueryTimestamp
;
A timestamp represents an absolute point in time, independent of any time zone or convention such as Daylight Savings Time.
BigQuery#timestamp
Parameter Name
Description
value
Date
| string
The time.
Returns
valueToQueryParameter_(value, providedType)
static
valueToQueryParameter_
(
value
:
any
,
providedType
?:
string
|
ProvidedTypeStruct
|
ProvidedTypeArray
)
:
bigquery
.
IQueryParameter
;
Parameters Name
Description
value
any
The value.
providedType
string | ProvidedTypeStruct
| ProvidedTypeArray
Provided query parameter type.
Returns Type
Description
bigquery.IQueryParameter
{object} A properly-formed queryParameter
object.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-04 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,[]]