Trình tạo cho LookerDataSourceSpecBuilder.
Ví dụ này cho thấy cách tạo trình tạo Đặc tả nguồn dữ liệu Looker mới.
const lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker();
Phương thức
| Phương thức | Kiểu dữ liệu trả về | Mô tả ngắn |
|---|---|---|
build() | Data | Tạo đặc tả nguồn dữ liệu từ các chế độ cài đặt trong trình tạo này. |
copy() | Data | Tạo Data dựa trên các chế độ cài đặt của nguồn dữ liệu này. |
get | String | Lấy tên của bản khám phá Looker trong mô hình. |
get | String | Lấy URL của thực thể Looker. |
get | String | Lấy tên của mô hình Looker trong thực thể. |
get | Data | Lấy các tham số của nguồn dữ liệu. |
get | Data | Lấy loại nguồn dữ liệu. |
remove | Looker | Xoá tất cả các tham số. |
remove | Looker | Xoá tham số đã chỉ định. |
set | Looker | Đặt tên bản khám phá trong mô hình Looker. |
set | Looker | Đặt URL thực thể cho Looker. |
set | Looker | Đặt tên mô hình Looker trong thực thể Looker. |
set | Looker | Thêm một tham số hoặc nếu tham số có tên tồn tại, hãy cập nhật ô nguồn của tham số đó cho trình tạo đặc tả nguồn dữ liệu
thuộc loại Data. |
Tài liệu chi tiết
build()
Tạo đặc tả nguồn dữ liệu từ các chế độ cài đặt trong trình tạo này. Bạn phải sử dụng as...() để chỉ định loại nguồn dữ liệu trước khi tạo.
Mã mẫu sau đây tạo Đặc tả nguồn dữ liệu BigQuery.
const bigQueryDataSourceSpec = 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();
Mẫu mã sau đây tạo Đặc tả nguồn dữ liệu Looker.
const lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker(); const lookerSpec = lookerDataSourceSpecBuilder.setExploreName('my explore name') .setInstanceUrl('my instance url') .setModelName('my model name') .build();
Cầu thủ trả bóng
DataSourceSpec – Đặc tả nguồn dữ liệu.
copy()
Tạo DataSourceSpecBuilder dựa trên các chế độ cài đặt của nguồn dữ liệu này.
// 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();
Cầu thủ trả bóng
DataSourceSpecBuilder – Trình tạo.
getExploreName()
Lấy tên của bản khám phá Looker trong mô hình.
// TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker(); const exploreName = lookerDataSourceSpec.getExploreName(); Logger.log(exploreName);
Cầu thủ trả bóng
String – Tên của bản khám phá Looker.
getInstanceUrl()
Lấy URL của thực thể Looker.
// TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker(); const instanceUrl = lookerDataSourceSpec.getInstanceUrl(); Logger.log(instanceUrl);
Cầu thủ trả bóng
String – URL của thực thể Looker.
getModelName()
Lấy tên của mô hình Looker trong thực thể.
// TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker(); const modelName = lookerDataSourceSpec.getModelName(); Logger.log(modelName);
Cầu thủ trả bóng
String – Tên của mô hình Looker.
getParameters()
Lấy các tham số của nguồn dữ liệu.
// 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();
Phương thức này chỉ dùng được cho nguồn dữ liệu BigQuery.
Cầu thủ trả bóng
DataSourceParameter[] – Danh sách tham số.
getType()
Lấy loại nguồn dữ liệu.
// 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();
Cầu thủ trả bóng
DataSourceType – Loại nguồn dữ liệu.
removeAllParameters()
Xoá tất cả các tham số.
const specBuilder = SpreadsheetApp.newDataSourceSpec(); specBuilder.removeAllParameters();
Cầu thủ trả bóng
LookerDataSourceSpecBuilder – Trình tạo, để tạo chuỗi.
removeParameter(parameterName)
Xoá tham số đã chỉ định.
const specBuilder = SpreadsheetApp.newDataSourceSpec(); specBuilder.removeParameter('x');
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
parameter | String | Tên của tham số cần xoá. |
Cầu thủ trả bóng
LookerDataSourceSpecBuilder – Trình tạo, để tạo chuỗi.
setExploreName(exploreName)
Đặt tên bản khám phá trong mô hình Looker.
const lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker(); // TODO(developer): replace explore name with your own lookerDataSourceSpecBuilder.setExploreName('my explore name');
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
explore | String | Tên bản khám phá trong mô hình Looker đã chọn. |
Cầu thủ trả bóng
LookerDataSourceSpecBuilder – Trình tạo này, để tạo chuỗi.
setInstanceUrl(instanceUrl)
Đặt URL thực thể cho Looker.
const lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker(); // TODO(developer): replace instance url with your own lookerDataSourceSpecBuilder.setInstanceUrl('my instance url');
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
instance | String | URL của thực thể Looker. |
Cầu thủ trả bóng
LookerDataSourceSpecBuilder – Trình tạo, để tạo chuỗi.
setModelName(modelName)
Đặt tên mô hình Looker trong thực thể Looker.
const lookerDataSourceSpecBuilder = SpreadsheetApp.newDataSourceSpec().asLooker(); // TODO(developer): replace model name with your own lookerDataSourceSpecBuilder.setModelName('my model name');
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
model | String | Tên mô hình trong thực thể Looker. |
Cầu thủ trả bóng
LookerDataSourceSpecBuilder – Trình tạo, để tạo chuỗi.
setParameterFromCell(parameterName, sourceCell)
Thêm một tham số hoặc nếu tham số có tên tồn tại, hãy cập nhật ô nguồn của tham số đó cho trình tạo đặc tả nguồn dữ liệu thuộc loại DataSourceType.BIGQUERY.
Phương thức này chỉ dùng được cho nguồn dữ liệu BigQuery.
const specBuilder = SpreadsheetApp.newDataSourceSpec().asBigQuery(); specBuilder.setParameterFromCell('x', 'A1'); const bigQuerySpec = specBuilder.build();
Tham số
| Tên | Loại | Mô tả |
|---|---|---|
parameter | String | Tên tham số. |
source | String | Ô nguồn, như được chỉ định trong ký hiệu A1. |
Cầu thủ trả bóng
LookerDataSourceSpecBuilder – Trình tạo, để tạo chuỗi.