Class LookerDataSourceSpecBuilder Stay organized with collections Save and categorize content based on your preferences.
Page Summary
LookerDataSourceSpecBuilder is used to create a new Looker Data Source Spec builder in Apps Script.
You can build a data source specification from the builder's settings using the
build()method.The builder provides methods to get and set the Looker explore name, instance URL, and model name.
You can manage parameters using methods like
getParameters(),removeAllParameters(), andremoveParameter().
The builder forLooker.
This example shows how to create a new Looker Data Source Spec builder.
constlookerDataSourceSpecBuilder=SpreadsheetApp.newDataSourceSpec().asLooker();
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 name of the Looker explore in the model. |
get | String | Gets the URL of the Looker instance. |
get | String | Gets the name of the Looker model in the instance. |
get | Data | Gets the parameters of the data source. |
get | Data | Gets the type of the data source. |
remove | Looker | Removes all the parameters. |
remove | Looker | Removes the specified parameter. |
set | Looker | Sets the explore name in the Looker model. |
set | Looker | Sets the instance URL for Looker. |
set | Looker | Sets the Looker model name in the Looker instance. |
set | Looker | Adds a parameter, or if the parameter with the name exists, updates its source cell for datasource spec builders of typeData. |
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.
getExploreName()
Gets the name of the Looker explore in the model.
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constlookerDataSourceSpec=ss.getDataSources()[0].getSpec().asLooker();constexploreName=lookerDataSourceSpec.getExploreName();Logger.log(exploreName);
Return
String — The name of the Looker explore.
getInstanceUrl()
Gets the URL of the Looker instance.
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constlookerDataSourceSpec=ss.getDataSources()[0].getSpec().asLooker();constinstanceUrl=lookerDataSourceSpec.getInstanceUrl();Logger.log(instanceUrl);
Return
String — The URL of the Looker instance.
getModelName()
Gets the name of the Looker model in the instance.
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constlookerDataSourceSpec=ss.getDataSources()[0].getSpec().asLooker();constmodelName=lookerDataSourceSpec.getModelName();Logger.log(modelName);
Return
String — The name of the Looker model.
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.
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
Looker — 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
Looker — The builder, for chaining.
setExploreName(exploreName)
Sets the explore name in the Looker model.
constlookerDataSourceSpecBuilder=SpreadsheetApp.newDataSourceSpec().asLooker();// TODO(developer): replace explore name with your ownlookerDataSourceSpecBuilder.setExploreName('my explore name');
Parameters
| Name | Type | Description |
|---|---|---|
explore | String | The explore name in the selected Looker model. |
Return
Looker — This builder, for chaining.
setInstanceUrl(instanceUrl)
Sets the instance URL for Looker.
constlookerDataSourceSpecBuilder=SpreadsheetApp.newDataSourceSpec().asLooker();// TODO(developer): replace instance url with your ownlookerDataSourceSpecBuilder.setInstanceUrl('my instance url');
Parameters
| Name | Type | Description |
|---|---|---|
instance | String | The URL of the Looker instance. |
Return
Looker — The builder, for chaining.
setModelName(modelName)
Sets the Looker model name in the Looker instance.
constlookerDataSourceSpecBuilder=SpreadsheetApp.newDataSourceSpec().asLooker();// TODO(developer): replace model name with your ownlookerDataSourceSpecBuilder.setModelName('my model name');
Parameters
| Name | Type | Description |
|---|---|---|
model | String | The model name in the Looker instance. |
Return
Looker — The 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
Looker — 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.