Class BigQueryDataSourceSpecBuilder

BigQueryDataSourceSpecBuilder

The builder for BigQueryDataSourceSpec.

Methods

MethodReturn typeBrief description
build()DataSourceSpecBuilds a data source specification from the settings in this builder.
copy()DataSourceSpecBuilderCreates a DataSourceSpecBuilder based on this data source's settings.
getDatasetId()StringGets the BigQuery dataset ID.
getParameters()DataSourceParameter[]Gets the parameters of the data source.
getProjectId()StringGets the billing project ID.
getRawQuery()StringGets the raw query string.
getTableId()StringGets the BigQuery table ID.
getTableProjectId()StringGets the BigQuery project ID for the table.
getType()DataSourceTypeGets the type of the data source.
removeAllParameters()BigQueryDataSourceSpecBuilderRemoves all the parameters.
removeParameter(parameterName)BigQueryDataSourceSpecBuilderRemoves the specified parameter.
setDatasetId(datasetId)BigQueryDataSourceSpecBuilderSets the BigQuery dataset ID.
setParameterFromCell(parameterName, sourceCell)BigQueryDataSourceSpecBuilderAdds a parameter, or if the parameter with the name exists, updates its source cell for data source spec builders of type DataSourceType.BIGQUERY.
setProjectId(projectId)BigQueryDataSourceSpecBuilderSets the billing BigQuery project ID.
setRawQuery(rawQuery)BigQueryDataSourceSpecBuilderSets the raw query string.
setTableId(tableId)BigQueryDataSourceSpecBuilderSets the BigQuery table ID.
setTableProjectId(projectId)BigQueryDataSourceSpecBuilderSets the BigQuery project ID for the table.

Detailed documentation

build()

Builds a data source specification from the settings in this builder. Must use as...() to specify a data source type before building.

The following code sample builds a BigQuery DataSource Spec.

var bigQueryDataSourceSpec = 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.

var lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker();
var lookerSpec = lookerDataSourceSpecBuilder.setExploreName("my explore name")
                                            .setInstanceUrl("my instance url")
                                            .setModelName("my model name")
                                            .build();

Return

DataSourceSpec — The data source specification.


copy()

Creates a DataSourceSpecBuilder based on this data source's settings.

// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');
var spec = ss.getDataSources()[0].getSpec();

var newSpec = spec.copy();

Return

DataSourceSpecBuilder — 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.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');
var spec = ss.getDataSources()[0].getSpec();
var parameters = spec.getParameters();

This method is only available for BigQuery data sources.

Return

DataSourceParameter[] — 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.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');
var spec = ss.getDataSources()[0].getSpec();
var type = spec.getType();

Return

DataSourceType — The data source type.


removeAllParameters()

Removes all the parameters.

var specBuilder = SpreadsheetApp.newDataSourceSpec();
specBuilder.removeAllParameters();

Return

BigQueryDataSourceSpecBuilder — The builder, for chaining.


removeParameter(parameterName)

Removes the specified parameter.

var specBuilder = SpreadsheetApp.newDataSourceSpec();
specBuilder.removeParameter("x");

Parameters

NameTypeDescription
parameterNameStringThe name of the parameter to remove.

Return

BigQueryDataSourceSpecBuilder — The builder, for chaining.


setDatasetId(datasetId)

Sets the BigQuery dataset ID.

Parameters

NameTypeDescription
datasetIdStringThe ID of the dataset.

Return

BigQueryDataSourceSpecBuilder — This builder, for chaining.


setParameterFromCell(parameterName, sourceCell)

Adds a parameter, or if the parameter with the name exists, updates its source cell for data source spec builders of type DataSourceType.BIGQUERY.

This method is only available for BigQuery data sources.

var specBuilder = SpreadsheetApp.newDataSourceSpec().asBigQuery();
specBuilder.setParameterFromCell("x", "A1");
var bigQuerySpec = specBuilder.build();

Parameters

NameTypeDescription
parameterNameStringThe parameter name.
sourceCellStringThe source cell, as specified in A1 notation.

Return

BigQueryDataSourceSpecBuilder — The builder, for chaining.


setProjectId(projectId)

Sets the billing BigQuery project ID.

Parameters

NameTypeDescription
projectIdStringThe ID of the billing project.

Return

BigQueryDataSourceSpecBuilder — The builder, for chaining.


setRawQuery(rawQuery)

Sets the raw query string.

Parameters

NameTypeDescription
rawQueryStringThe raw query string.

Return

BigQueryDataSourceSpecBuilder — The builder, for chaining.


setTableId(tableId)

Sets the BigQuery table ID.

Parameters

NameTypeDescription
tableIdStringThe ID of the table.

Return

BigQueryDataSourceSpecBuilder — This builder, for chaining.


setTableProjectId(projectId)

Sets the BigQuery project ID for the table.

Parameters

NameTypeDescription
projectIdStringThe project ID of the BigQuery table.

Return

BigQueryDataSourceSpecBuilder — The builder, for chaining.