How to split schema into multiple files for same cube
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
Hi,
Did you see this tutorial?
If it not helpful for you, please let me know.
Thanks.
@Levhav Thanks. I'll take a look.
@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.
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;
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.
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