Accedi alle impostazioni generali di una specifica dell'origine dati esistente. Per accedere alla specifica dell'origine dati per un determinato tipo, utilizza il metodo as...(). Per creare una nuova specifica dell'origine dati, utilizza SpreadsheetApp.newDataSourceSpec().
Utilizza questa classe solo con i dati connessi a un database.
Questo esempio mostra come ottenere informazioni da una specifica dell'origine dati BigQuery.
const dataSourceTable = SpreadsheetApp.getActive() .getSheetByName('Data Sheet 1') .getDataSourceTables()[0]; const spec = dataSourceTable.getDataSource().getSpec(); if (spec.getType() === SpreadsheetApp.DataSourceType.BIGQUERY) { const bqSpec = spec.asBigQuery(); Logger.log('Project ID: %s\n', bqSpec.getProjectId()); Logger.log('Raw query string: %s\n', bqSpec.getRawQuery()); }
Questo esempio mostra come ottenere informazioni da una specifica dell'origine dati Looker. L'utilizzo di asLooker() restituisce un oggetto LookerDataSourceSpec.
// TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); const spec = ss.getDataSources()[0].getSpec().asLooker(); if (spec.getType() === SpreadsheetApp.DataSourceType.LOOKER) { const lookerSpec = spec.asLooker(); Logger.log('Looker instance URL: %s\n', lookerSpec.getInstanceUrl()); }
Metodi
| Metodo | Tipo restituito | Breve descrizione |
|---|---|---|
as | Big | Ottiene la specifica per l'origine dati BigQuery. |
as | Looker | Ottiene la specifica per l'origine dati Looker. |
copy() | Data | Crea un oggetto Data in base alle impostazioni di questa origine dati. |
get | Data | Ottiene i parametri dell'origine dati. |
get | Data | Ottiene il tipo di origine dati. |
Documentazione dettagliata
asBigQuery()
Ottiene la specifica per l'origine dati BigQuery.
Indietro
BigQueryDataSourceSpec : la specifica dell'origine dati BigQuery.
asLooker()
Ottiene la specifica per l'origine dati Looker.
// TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); const spec = ss.getDataSources()[0].getSpec().asLooker();
Indietro
LookerDataSourceSpec : la specifica dell'origine dati Looker.
copy()
Crea un oggetto DataSourceSpecBuilder in base alle impostazioni di questa origine dati.
// TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); const spec = ss.getDataSources()[0].getSpec(); const newSpec = spec.copy();
Indietro
DataSourceSpecBuilder : il builder.
getParameters()
Ottiene i parametri dell'origine dati.
// TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); const spec = ss.getDataSources()[0].getSpec(); const parameters = spec.getParameters();
Questo metodo è disponibile solo per le origini dati BigQuery.
Indietro
DataSourceParameter[] : l'elenco dei parametri.
getType()
Ottiene il tipo di origine dati.
// TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); const spec = ss.getDataSources()[0].getSpec(); const type = spec.getType();
Indietro
DataSourceType : il tipo di origine dati.