cube icon indicating copy to clipboard operation
cube copied to clipboard

How to split schema into multiple files for same cube

Open devopsprosiva opened this issue 6 years ago • 6 comments

Problem

Hi,

I've one schema with a lot of metric queries. Is there a way to split the schema into multiple files for the same cube?

Thanks, Siva

devopsprosiva avatar Sep 07 '20 07:09 devopsprosiva

Hi,
Did you see this tutorial? If it not helpful for you, please let me know. Thanks.

VictorTrapenok avatar Sep 08 '20 07:09 VictorTrapenok

@Levhav Thanks. I'll take a look.

devopsprosiva avatar Sep 08 '20 09:09 devopsprosiva

@Levhav The above example extends a new cube ProductPurchases using the BaseEvents cube. I'm not looking for that. What I need is to breakdown BaseEvents cube into multiple files. In my case, I only have one cube.

devopsprosiva avatar Sep 08 '20 09:09 devopsprosiva

You can use require and all other JavaScript functions in the cube configuration file.

For example, you can use something like this:

let measures = require('/var/www/chat.js');    
 
cube(`MyCube`, {
  sql: `SELECT 't' as schem, rand() as data `,
  measures: measures,
  dimensions:{  
    schema:{
      sql: 'schem',
      type: 'string'
    }
  }, 
})

And file measures.js

const measures = { 
        one:{
            sql: () => 'data',
            type: 'number'
        }
    }
 
module.exports = measures;

More information here

VictorTrapenok avatar Sep 09 '20 02:09 VictorTrapenok

Hi, @devopsprosiva
Could you please elaborate on your use case? Why your config so big? Do you use code generation for it, or maybe you have something other reasons? Thanks.

VictorTrapenok avatar Sep 11 '20 04:09 VictorTrapenok

Hi @Levhav,

Sorry for the delay in responding. Coming to my use case, I only have one view in the database. But I can write lot of queries based on different filters on the data. That's the reason why the schema file is getting big. Hope this helps in understanding better.

Thanks, Siva

devopsprosiva avatar Sep 23 '20 03:09 devopsprosiva