Class 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
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-12-22。
[null,null,["最后更新时间 (UTC):2024-12-22。"],[[["`getSchemaResponse` facilitates the creation of a schema for your Data Studio Community Connector, defining the structure of data your connector provides."],["It allows you to specify dimensions and metrics, including their data types, descriptions, and IDs, using the `fields` object."],["The `build()` method finalizes the schema definition and returns a validated object in the format required by Data Studio."],["Additional methods like `printJson()` and `setFields()` are available for debugging and further schema customization."]]],["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"]]