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
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-22 (世界標準時間)。
[null,null,["上次更新時間: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"]]