Class DataSourceSpecBuilder

DataSourceSpecBuilder

The builder for DataSourceSpec. To create a specification for certain type, use as...() method. To create a new builder, use SpreadsheetApp.newDataSourceSpec(). To use the specification, see DataSourceTable.

Only use this class with data that's connected to a database.

This examples show how to build a BigQuery data source specification.

var spec = SpreadsheetApp.newDataSourceSpec()
           .asBigQuery()
           .setProjectId('big_query_project')
           .setRawQuery('select @FIELD from table limit @LIMIT')
           .setParameterFromCell('FIELD', 'Sheet1!A1')
           .setParameterFromCell('LIMIT', 'namedRangeCell')
           .build();

Methods

MethodReturn typeBrief description
asBigQuery()BigQueryDataSourceSpecBuilderGets the builder for BigQuery data source.
build()DataSourceSpecBuilds a data source specification from the settings in this builder.
copy()DataSourceSpecBuilderCreates a DataSourceSpecBuilder based on this data source's settings.
getParameters()DataSourceParameter[]Gets the parameters of the data source.
getType()DataSourceTypeGets the type of the data source.
removeAllParameters()DataSourceSpecBuilderRemoves all the parameters.
removeParameter(parameterName)DataSourceSpecBuilderRemoves the specified parameter.
setParameterFromCell(parameterName, sourceCell)DataSourceSpecBuilderAdds a parameter, or if the parameter with the name exists, updates its source cell.

Detailed documentation

asBigQuery()

Gets the builder for BigQuery data source.

Return

BigQueryDataSourceSpecBuilder — The BigQuery data source specification builder.


build()

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

Return

DataSourceSpec — The data source specification.


copy()

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

Return

DataSourceSpecBuilder — The builder.


getParameters()

Gets the parameters of the data source.

Return

DataSourceParameter[] — The parameter list.


getType()

Gets the type of the data source.

Return

DataSourceType — The data source type.


removeAllParameters()

Removes all the parameters.

Return

DataSourceSpecBuilder — The builder, for chaining.


removeParameter(parameterName)

Removes the specified parameter.

Parameters

NameTypeDescription
parameterNameStringThe name of the parameter to remove.

Return

DataSourceSpecBuilder — The builder, for chaining.


setParameterFromCell(parameterName, sourceCell)

Adds a parameter, or if the parameter with the name exists, updates its source cell.

Parameters

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

Return

DataSourceSpecBuilder — The builder, for chaining.