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 Spreadsheet.
Utilizza questa classe solo con dati collegati 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 di Looker. L'utilizzo di as restituisce un oggetto 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(); 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 | Recupera la specifica per l'origine dati BigQuery. |
as | Looker | Recupera la specifica per l'origine dati di Looker. |
copy() | Data | Crea un Data in base alle impostazioni di questa origine dati. |
get | Data | Recupera i parametri dell'origine dati. |
get | Data | Recupera il tipo di origine dati. |
Documentazione dettagliata
as Big Query()
Recupera la specifica per l'origine dati BigQuery.
Invio
Big: la specifica dell'origine dati BigQuery.
as Looker()
Recupera la specifica per l'origine dati di 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();
Invio
Looker: la specifica dell'origine dati di Looker.
copy()
Crea un Data 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();
Invio
Data: il builder.
get Parameters()
Recupera 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.
Invio
Data: l'elenco dei parametri.
get Type()
Recupera 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();
Invio
Data: il tipo di origine dati.