Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Specificadell'originedatidi Looker
Un DataSourceSpec utilizzato per accedere specificamente alle specifiche dell'origine dati di Looker esistente. Per creare una nuova specifica dell'origine dati, utilizza SpreadsheetApp.newDataSourceSpec().
Questo esempio mostra come ottenere la specifica dell'origine dati di Looker da un foglio con una sola connessione a Looker.
// 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();
// 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();
Recupera il nome dell'esplorazione di Looker nel modello.
// 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);
Invio
String: il nome dell'esplorazione di Looker.
getInstanceUrl()
Recupera l'URL dell'istanza di Looker.
// 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);
Invio
String: l'URL dell'istanza di Looker.
getModelName()
Recupera il nome del modello di Looker nell'istanza.
// 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);
Invio
String: il nome del modello di Looker.
getParameters()
Recupera i parametri dell'origine dati.
// 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();
Questo metodo è disponibile solo per le origini dati BigQuery.
// 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();
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eLookerDataSourceSpec\u003c/code\u003e enables access to existing Looker data source specifications within Google Sheets.\u003c/p\u003e\n"],["\u003cp\u003eTo create new data source specifications, use \u003ccode\u003eSpreadsheetApp.newDataSourceSpec()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve details such as explore name, instance URL, and model name from a \u003ccode\u003eLookerDataSourceSpec\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eSeveral methods, including \u003ccode\u003ecopy()\u003c/code\u003e, \u003ccode\u003egetExploreName()\u003c/code\u003e, \u003ccode\u003egetInstanceUrl()\u003c/code\u003e, \u003ccode\u003egetModelName()\u003c/code\u003e, \u003ccode\u003egetParameters()\u003c/code\u003e, and \u003ccode\u003egetType()\u003c/code\u003e, are available for interacting with Looker data source specifications.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetParameters()\u003c/code\u003e method is specific to BigQuery data sources and retrieves their parameters.\u003c/p\u003e\n"]]],["The `LookerDataSourceSpec` accesses existing Looker data sources. Key actions include retrieving data source details via methods: `getExploreName()` gets the Looker explore name, `getInstanceUrl()` gets the Looker instance URL, and `getModelName()` gets the Looker model name. `getParameters()` retrieves data source parameters (available only for BigQuery), and `getType()` gets the data source type. The `copy()` method creates a `DataSourceSpecBuilder` based on current settings. You can retrieve the looker data source by using `getDataSources()[0].getSpec().asLooker()`.\n"],null,["# Class LookerDataSourceSpec\n\nLookerDataSourceSpec\n\nA [DataSourceSpec](/apps-script/reference/spreadsheet/data-source-spec) which is used to access specifically the existing Looker data source\nspecifications. To create a new data source specification, use [SpreadsheetApp.newDataSourceSpec()](/apps-script/reference/spreadsheet/spreadsheet-app#newDataSourceSpec()).\n\nThis example shows how you can get the Looker data source spec from a sheet which has just one\nLooker connection.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|\n| [copy()](#copy()) | [DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) | Creates a [DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) based on this data source's settings. |\n| [getExploreName()](#getExploreName()) | `String` | Gets the name of the Looker explore in the model. |\n| [getInstanceUrl()](#getInstanceUrl()) | `String` | Gets the URL of the Looker instance. |\n| [getModelName()](#getModelName()) | `String` | Gets the name of the Looker model in the instance. |\n| [getParameters()](#getParameters()) | [DataSourceParameter[]](/apps-script/reference/spreadsheet/data-source-parameter) | Gets the parameters of the data source. |\n| [getType()](#getType()) | [DataSourceType](/apps-script/reference/spreadsheet/data-source-type) | Gets the type of the data source. |\n\nDetailed documentation\n----------------------\n\n### `copy()`\n\nCreates a [DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) based on this data source's settings.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec();\n\nconst newSpec = spec.copy();\n```\n\n#### Return\n\n\n[DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) --- The builder.\n\n*** ** * ** ***\n\n### `get``Explore``Name()`\n\nGets the name of the Looker explore in the model.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\nconst exploreName = lookerDataSourceSpec.getExploreName();\nLogger.log(exploreName);\n```\n\n#### Return\n\n\n`String` --- The name of the Looker explore.\n\n*** ** * ** ***\n\n### `get``Instance``Url()`\n\nGets the URL of the Looker instance.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\nconst instanceUrl = lookerDataSourceSpec.getInstanceUrl();\nLogger.log(instanceUrl);\n```\n\n#### Return\n\n\n`String` --- The URL of the Looker instance.\n\n*** ** * ** ***\n\n### `get``Model``Name()`\n\nGets the name of the Looker model in the instance.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\nconst modelName = lookerDataSourceSpec.getModelName();\nLogger.log(modelName);\n```\n\n#### Return\n\n\n`String` --- The name of the Looker model.\n\n*** ** * ** ***\n\n### `get``Parameters()`\n\nGets the parameters of the data source.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec();\nconst parameters = spec.getParameters();\n```\n\nThis method is only available for BigQuery data sources.\n\n#### Return\n\n\n[DataSourceParameter[]](/apps-script/reference/spreadsheet/data-source-parameter) --- The parameter list.\n\n*** ** * ** ***\n\n### `get``Type()`\n\nGets the type of the data source.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec();\nconst type = spec.getType();\n```\n\n#### Return\n\n\n[DataSourceType](/apps-script/reference/spreadsheet/data-source-type) --- The data source type."]]