Class DataSourceSpec

  • DataSourceSpec allows access to the general settings of an existing data source spec.

  • Useas...() methods to access data source specs for specific types like BigQuery or Looker.

  • This class should only be used with data connected to a database.

  • You can create aDataSourceSpecBuilder based on an existing spec's settings using thecopy() method.

  • You can retrieve the parameters and the type of the data source spec usinggetParameters() andgetType().

DataSourceSpec

Access the general settings of an existing data source spec. To access data source spec forcertain type, useas...() method. To create a new data source spec, useSpreadsheetApp.newDataSourceSpec().

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

This example shows how to get information from a BigQuery data source spec.

constdataSourceTable=SpreadsheetApp.getActive().getSheetByName('Data Sheet 1').getDataSourceTables()[0];constspec=dataSourceTable.getDataSource().getSpec();if(spec.getType()===SpreadsheetApp.DataSourceType.BIGQUERY){constbqSpec=spec.asBigQuery();Logger.log('Project ID: %s\n',bqSpec.getProjectId());Logger.log('Raw query string: %s\n',bqSpec.getRawQuery());}

This example shows how to get information from a Looker data source spec. UsingasLooker() returns aLookerDataSourceSpec object.

// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constspec=ss.getDataSources()[0].getSpec().asLooker();if(spec.getType()===SpreadsheetApp.DataSourceType.LOOKER){constlookerSpec=spec.asLooker();Logger.log('Looker instance URL: %s\n',lookerSpec.getInstanceUrl());}

Methods

MethodReturn typeBrief description
asBigQuery()BigQueryDataSourceSpecGets the spec for BigQuery data source.
asLooker()LookerDataSourceSpecGets the spec for Looker data source.
copy()DataSourceSpecBuilderCreates aDataSourceSpecBuilder based on this data source's settings.
getParameters()DataSourceParameter[]Gets the parameters of the data source.
getType()DataSourceTypeGets the type of the data source.

Detailed documentation

asBigQuery()

Gets the spec for BigQuery data source.

Return

BigQueryDataSourceSpec — The BigQuery data source spec.


asLooker()

Gets the spec for Looker 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().asLooker();

Return

LookerDataSourceSpec — The Looker data source spec.


copy()

Creates aDataSourceSpecBuilder 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

DataSourceSpecBuilder — The builder.


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

DataSourceParameter[] — 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

DataSourceType — The data source type.

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.