rittmananalytics / droughty

Droughty helps keep your workflow dry
https://droughty.readthedocs.io/en/latest/
MIT License
62 stars 6 forks source link

Option to generate one cube definition per entity #46

Open olivierdupuis opened 1 year ago

olivierdupuis commented 1 year ago

The droughty cube functionality currently generates 3 files: base, integration and aggregate. This doesn't translate well with the way I organize my Cube deployments, where I have a cube definition per entity. So that would mean I have the dimensions, metrics and joins all defined in a single file.

Would it be possible to have the option to change how droughty generates the cube definitions so that instead of the above files, I end up with a single file per entity that would look something like the following...

cube('Events', {
  sql: `select * from analytics.events_fct`,

  dimensions: {
    eventPk: {
      primaryKey: true,
      sql: `event_pk`,
      type: `string`,
      shown: true
    },

    movementFk: {
      sql: `movement_fk`,
      type: `string`
    },

    eventDate: {
      sql: `event_date`,
      type: `time`
    },

    actionGeoCountryName: {
      sql: `action_geo_country_name`,
      type: `string`
    },
  },

  measures: {
    eventCount: {
      sql: `event_pk`,
      type: `count`
    }
  },

  joins: {
    Movements: {
      relationship: `belongsTo`,
      sql: `
        ${CUBE}.movement_fk = ${Movements.movementPk}
      `
    },
  },
});