Search code examples
looker-studiogetschema

Differences between LEGACY schema and Data Studio Apps Script Service


I'm having problems trying to migrate from legacy schema object to new Data Studio Apps Script Service.

For example in my old schema object I have this dimension:

  {
    "name" : "datetxt",
    "label" : "Date",
    "description" : "date of sale",
    "dataType" : "STRING",
    "group" : "Dates",
    "semantics" : {
      "conceptType" : "DIMENSION",
      "semanticGroup" : "DATETIME",
      "semanticType " : "YEAR_MONTH_DAY",
      "isReaggregatable" : false
    }
  }

When using the new method I translate it this way:

 var cc = DataStudioApp.createCommunityConnector();
 var fields = cc.getFields();      
 var types = cc.FieldType;
 var aggregations = cc.AggregationType;

[...]

fields.newDimension()
      .setId('datetxt')
      .setName('Date')
      .setDescription('date of sale')
      .setGroup('Dates')                /* or types.DATETIME ???*/
      .setType(types.YEAR_MONTH_DAY)    /* or types.TEXT ??? */        
      .setIsReaggregatable(false)

the documentation is not clear enough in which group and type should I use when declaring the object with the new way. Can anyone help?. Thanks.


Solution

  • Your new code looks correct. We got rid of needing to separately set dataType and semanticType since a semantic type always maps to a specific dataType.

    Groups are user-defined & just there so Data Studio can group like fields together in some parts of the UI. Typically, groups are more useful if you have a very large number of fields.