Class DataSourceSpecBuilder

DataSourceSpecBuilder

DataSourceSpec의 빌더입니다. 특정 유형의 사양을 만들려면 as...() 메서드를 사용합니다. 새 빌더를 만들려면 SpreadsheetApp.newDataSourceSpec()를 사용합니다. 사양을 사용하려면 DataSourceTable를 참고하세요.

이 클래스는 데이터베이스에 연결된 데이터에만 사용합니다.

이 예에서는 BigQuery 데이터 소스 사양을 빌드하는 방법을 보여줍니다.

const spec = SpreadsheetApp.newDataSourceSpec()                  .asBigQuery()                  .setProjectId('big_query_project')                  .setRawQuery('select @FIELD from table limit @LIMIT')                  .setParameterFromCell('FIELD', 'Sheet1!A1')                  .setParameterFromCell('LIMIT', 'namedRangeCell')                  .build();

이 예에서는 Looker 데이터 소스 사양을 빌드하는 방법을 보여줍니다. build()를 사용한 후 LookerDataSourceSpec 객체를 반환합니다.

const spec = SpreadsheetApp.newDataSourceSpec()                  .asLooker()                  .setInstanceUrl('https://looker_instance_url.com')                  .setModelName('model_name')                  .setExploreName('explore_name')                  .build();

메서드

메서드반환 유형간략한 설명
asBigQuery()BigQueryDataSourceSpecBuilderBigQuery 데이터 소스의 빌더를 가져옵니다.
asLooker()LookerDataSourceSpecBuilderLooker 데이터 소스의 빌더를 가져옵니다.
build()DataSourceSpec이 빌더의 설정에서 데이터 소스 사양을 빌드합니다.
copy()DataSourceSpecBuilder이 데이터 소스의 설정을 기반으로 DataSourceSpecBuilder를 만듭니다.
getParameters()DataSourceParameter[]데이터 소스의 매개변수를 가져옵니다.
getType()DataSourceType데이터 소스의 유형을 가져옵니다.
removeAllParameters()DataSourceSpecBuilder모든 매개변수를 삭제합니다.
removeParameter(parameterName)DataSourceSpecBuilder지정된 매개변수를 삭제합니다.
setParameterFromCell(parameterName, sourceCell)DataSourceSpecBuilder매개변수를 추가하거나 이름이 지정된 매개변수가 있는 경우 DataSourceType.BIGQUERY 유형의 데이터 소스 사양 빌더의 소스 셀을 업데이트합니다.

자세한 문서

asBigQuery()

BigQuery 데이터 소스의 빌더를 가져옵니다.

리턴

BigQueryDataSourceSpecBuilder: BigQuery 데이터 소스 사양 빌더입니다.


asLooker()

Looker 데이터 소스의 빌더를 가져옵니다.

const spec = SpreadsheetApp.newDataSourceSpec()                  .asLooker()                  .setInstanceUrl('https://looker_instance_url.com')                  .setModelName('model_name')                  .setExploreName('explore_name')                  .build();

리턴

LookerDataSourceSpecBuilder: Looker 데이터 소스 사양 작성 도구입니다.


build()

이 빌더의 설정에서 데이터 소스 사양을 빌드합니다. 빌드하기 전에 as...()를 사용하여 데이터 소스 유형을 지정해야 합니다.

다음 코드 샘플은 BigQuery DataSource 사양을 빌드합니다.

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();

다음 코드 샘플은 Looker DataSource 사양을 빌드합니다.

const lookerDataSourceSpecBuilder =     SpreadsheetApp.newDataSourceSpec().asLooker(); const lookerSpec = lookerDataSourceSpecBuilder.setExploreName('my explore name')                        .setInstanceUrl('my instance url')                        .setModelName('my model name')                        .build();

리턴

DataSourceSpec: 데이터 소스 사양입니다.


copy()

이 데이터 소스의 설정을 기반으로 DataSourceSpecBuilder를 만듭니다.

// 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();

리턴

DataSourceSpecBuilder: 빌더입니다.


getParameters()

데이터 소스의 매개변수를 가져옵니다.

// 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();

이 메서드는 BigQuery 데이터 소스에서만 사용할 수 있습니다.

리턴

DataSourceParameter[]: 매개변수 목록입니다.


getType()

데이터 소스의 유형을 가져옵니다.

// 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();

리턴

DataSourceType: 데이터 소스 유형입니다.


removeAllParameters()

모든 매개변수를 삭제합니다.

const specBuilder = SpreadsheetApp.newDataSourceSpec(); specBuilder.removeAllParameters();

리턴

DataSourceSpecBuilder: 연결을 위한 빌더입니다.


removeParameter(parameterName)

지정된 매개변수를 삭제합니다.

const specBuilder = SpreadsheetApp.newDataSourceSpec(); specBuilder.removeParameter('x');

매개변수

이름유형설명
parameterNameString삭제할 매개변수의 이름입니다.

리턴

DataSourceSpecBuilder: 연결을 위한 빌더입니다.


setParameterFromCell(parameterName, sourceCell)

매개변수를 추가하거나 이름이 지정된 매개변수가 있는 경우 DataSourceType.BIGQUERY 유형의 데이터 소스 사양 빌더의 소스 셀을 업데이트합니다.

이 메서드는 BigQuery 데이터 소스에서만 사용할 수 있습니다.

const specBuilder = SpreadsheetApp.newDataSourceSpec().asBigQuery(); specBuilder.setParameterFromCell('x', 'A1'); const bigQuerySpec = specBuilder.build();

매개변수

이름유형설명
parameterNameString매개변수 이름입니다.
sourceCellStringA1 표기법으로 지정된 소스 셀입니다.

리턴

DataSourceSpecBuilder: 연결을 위한 빌더입니다.