Class BigQueryDataSourceSpecBuilder Stay organized with collections Save and categorize content based on your preferences.
Page Summary
BigQueryDataSourceSpecBuilder is used to build a data source specification for BigQuery.
It provides methods to get and set the dataset ID, project ID, table ID, and raw query.
You can manage parameters for the data source, including adding, removing, and setting them from a cell reference.
The
build()method finalizes the configuration and returns a DataSourceSpec object.
The builder forBig.
Methods
| Method | Return type | Brief description |
|---|---|---|
build() | Data | Builds a data source specification from the settings in this builder. |
copy() | Data | Creates aData based on this data source's settings. |
get | String | Gets the BigQuery dataset ID. |
get | Data | Gets the parameters of the data source. |
get | String | Gets the billing project ID. |
get | String | Gets the raw query string. |
get | String | Gets the BigQuery table ID. |
get | String | Gets the BigQuery project ID for the table. |
get | Data | Gets the type of the data source. |
remove | Big | Removes all the parameters. |
remove | Big | Removes the specified parameter. |
set | Big | Sets the BigQuery dataset ID. |
set | Big | Adds a parameter, or if the parameter with the name exists, updates its source cell for datasource spec builders of typeData. |
set | Big | Sets the billing BigQuery project ID. |
set | Big | Sets the raw query string. |
set | Big | Sets the BigQuery table ID. |
set | Big | Sets the BigQuery project ID for the table. |
Detailed documentation
build()
Builds a data source specification from the settings in this builder. Must useas...()to specify a data source type before building.
The following code sample builds a BigQuery DataSource Spec.
constbigQueryDataSourceSpec=SpreadsheetApp.newDataSourceSpec().asBigQuery();// TODO(developer): Replace with the required dataset, project and table IDs.bigQueryDataSourceSpec.setDatasetId('my data set id');bigQueryDataSourceSpec.setProjectId('my project id');bigQueryDataSourceSpec.setTableId('my table id');bigQueryDataSourceSpec.build();
The following code sample builds a Looker DataSource Spec.
constlookerDataSourceSpecBuilder=SpreadsheetApp.newDataSourceSpec().asLooker();constlookerSpec=lookerDataSourceSpecBuilder.setExploreName('my explore name').setInstanceUrl('my instance url').setModelName('my model name').build();
Return
Data — The data source specification.
copy()
Creates aData based on this data source's settings.
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constspec=ss.getDataSources()[0].getSpec();constnewSpec=spec.copy();
Return
Data — The builder.
getDatasetId()
Gets the BigQuery dataset ID.
Return
String — The dataset ID, or an empty string if the data source spec is defined by a raw query.
getParameters()
Gets the parameters of the data source.
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constspec=ss.getDataSources()[0].getSpec();constparameters=spec.getParameters();
This method is only available for BigQuery data sources.
Return
Data — The parameter list.
getProjectId()
Gets the billing project ID.
Return
String — The project ID.
getRawQuery()
Gets the raw query string.
Return
String — The raw query string.
getTableId()
Gets the BigQuery table ID.
Return
String — The table ID, or an empty string if the data source spec is defined by a raw query.
getTableProjectId()
Gets the BigQuery project ID for the table.
Return
String — The table project ID, or an empty string if the data source spec is defined by a raw query.
getType()
Gets the type of the data source.
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constspec=ss.getDataSources()[0].getSpec();consttype=spec.getType();
Return
Data — The data source type.
removeAllParameters()
Removes all the parameters.
constspecBuilder=SpreadsheetApp.newDataSourceSpec();specBuilder.removeAllParameters();
Return
Big — The builder, for chaining.
removeParameter(parameterName)
Removes the specified parameter.
constspecBuilder=SpreadsheetApp.newDataSourceSpec();specBuilder.removeParameter('x');
Parameters
| Name | Type | Description |
|---|---|---|
parameter | String | The name of the parameter to remove. |
Return
Big — The builder, for chaining.
setDatasetId(datasetId)
Sets the BigQuery dataset ID.
Parameters
| Name | Type | Description |
|---|---|---|
dataset | String | The ID of the dataset. |
Return
Big — This builder, for chaining.
setParameterFromCell(parameterName, sourceCell)
Adds a parameter, or if the parameter with the name exists, updates its source cell for datasource spec builders of typeData.
This method is only available for BigQuery data sources.
constspecBuilder=SpreadsheetApp.newDataSourceSpec().asBigQuery();specBuilder.setParameterFromCell('x','A1');constbigQuerySpec=specBuilder.build();
Parameters
| Name | Type | Description |
|---|---|---|
parameter | String | The parameter name. |
source | String | The source cell, as specified in A1 notation. |
Return
Big — The builder, for chaining.
setProjectId(projectId)
Sets the billing BigQuery project ID.
Parameters
| Name | Type | Description |
|---|---|---|
project | String | The ID of the billing project. |
Return
Big — The builder, for chaining.
setRawQuery(rawQuery)
Sets the raw query string.
Parameters
| Name | Type | Description |
|---|---|---|
raw | String | The raw query string. |
Return
Big — The builder, for chaining.
setTableId(tableId)
Sets the BigQuery table ID.
Parameters
| Name | Type | Description |
|---|---|---|
table | String | The ID of the table. |
Return
Big — This builder, for chaining.
setTableProjectId(projectId)
Sets the BigQuery project ID for the table.
Parameters
| Name | Type | Description |
|---|---|---|
project | String | The project ID of the BigQuery table. |
Return
Big — The builder, for chaining.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.