Class GetSchemaResponse
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
GetSchemaResponse
스크립트 프로젝트의 getSchema()
응답을 만드는 빌더입니다.
function getSchema() {
const cc = DataStudioApp.createCommunityConnector();
const fields = cc.getFields();
fields.newDimension()
.setId('Created')
.setName('Date Created')
.setDescription('The date that this was created')
.setType(cc.FieldType.YEAR_MONTH_DAY);
fields.newMetric()
.setId('Amount')
.setName('Amount (USD)')
.setDescription('The cost in US dollars')
.setType(cc.FieldType.CURRENCY_USD);
return cc.newGetSchemaResponse().setFields(fields).build();
}
자세한 문서
printJson()
이 객체의 JSON 표현을 출력합니다. 디버깅 전용입니다.
리턴
String
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003e\u003ccode\u003egetSchemaResponse\u003c/code\u003e facilitates the creation of a schema for your Data Studio Community Connector, defining the structure of data your connector provides.\u003c/p\u003e\n"],["\u003cp\u003eIt allows you to specify dimensions and metrics, including their data types, descriptions, and IDs, using the \u003ccode\u003efields\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ebuild()\u003c/code\u003e method finalizes the schema definition and returns a validated object in the format required by Data Studio.\u003c/p\u003e\n"],["\u003cp\u003eAdditional methods like \u003ccode\u003eprintJson()\u003c/code\u003e and \u003ccode\u003esetFields()\u003c/code\u003e are available for debugging and further schema customization.\u003c/p\u003e\n"]]],["The `getSchema()` function defines data fields for a script project using the `DataStudioApp` service. It creates a dimension field named \"Date Created\" of `YEAR_MONTH_DAY` type and a metric field \"Amount (USD)\" of `CURRENCY_USD` type. The `newGetSchemaResponse()` builder then compiles and validates these fields using `setFields()` before the final format for Data Studio is produced using `build()`. `printJson()` outputs a JSON representation for debugging.\n"],null,["# Class GetSchemaResponse\n\nGetSchemaResponse\n\nBuilder to create a `get``Schema()` response for your script project.\n\n```javascript\nfunction getSchema() {\n const cc = DataStudioApp.createCommunityConnector();\n const fields = cc.getFields();\n\n fields.newDimension()\n .setId('Created')\n .setName('Date Created')\n .setDescription('The date that this was created')\n .setType(cc.FieldType.YEAR_MONTH_DAY);\n\n fields.newMetric()\n .setId('Amount')\n .setName('Amount (USD)')\n .setDescription('The cost in US dollars')\n .setType(cc.FieldType.CURRENCY_USD);\n\n return cc.newGetSchemaResponse().setFields(fields).build();\n}\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------|------------------------|------------------------------------------------------------------------------|\n| [build()](#build()) | `Object` | Validates this object and returns it in the format needed by Data Studio. |\n| [printJson()](#printJson()) | `String` | Prints the JSON representation of this object. |\n| [setFields(fields)](#setFields(Fields)) | [GetSchemaResponse](#) | Sets the [Fields](/apps-script/reference/data-studio/fields) of the builder. |\n\nDetailed documentation\n----------------------\n\n### `build()`\n\nValidates this object and returns it in the format needed by Data Studio.\n\n#### Return\n\n\n`Object` --- The validated [GetSchemaResponse](#) object.\n\n*** ** * ** ***\n\n### `print``Json()`\n\nPrints the JSON representation of this object. This is for debugging only.\n\n#### Return\n\n\n`String`\n\n*** ** * ** ***\n\n### `set``Fields(fields)`\n\nSets the [Fields](/apps-script/reference/data-studio/fields) of the builder.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------|-----------------------------------------------------|--------------------|\n| `fields` | [Fields](/apps-script/reference/data-studio/fields) | The fields to set. |\n\n#### Return\n\n\n[GetSchemaResponse](#) --- This builder, for chaining."]]