Comments (9)
@gizmodus I see. So the original idea behind Cube.js schema: it's just JS code and it can be dynamically generated using any external information including data in your DB.
To make it possible to do we still lack couple of things though:
- Allow to import arbitrary Node.js modules in schema code.
- API to trigger schema recompile.
@gizmodus Do you think it can solve your problem if this stuff will be in place?
from cube.js.
@gizmodus That's pretty interesting one! Could you please elaborate a little bit more on a business use case for that?
from cube.js.
@paveltiunov Sure! We would like to show statistics to multiple organizational units in a hospital. Each organizational units has its own charts with different content. The definition of these charts is stored in a database in JSON format.
In many cases we can take the relevant data for statistics directly from the database. However, sometimes it would be handy to transform the raw data from the database with a few SQL commands and then use the output for our charts.
Example:
We would like to display a bar chart of the number of patients per week day. In MySQL this can be easily achieved with the following command: DAYNAME(createdAt)
If I haven't missed anything, to achieve this we have to add the following lines to our schema.js under 'dimensions':
createdatweekday: {
sql: 'DAYNAME(patientCreatedAt)',
type: 'string'
},
So, whenever an organizational unit comes with a new request for a chart, we have to change schema.js and ship a new build of our application.
However, if we could define these transformations directly in the query (which is part of our configuration for the individual organizational unit), we can add charts with special parameters without a change in the application code.
Hope you this is somewhat understandable, otherwise I'd be happy to elaborate more!
from cube.js.
@gizmodus Seems like the goal is to create custom dimensions based on some config stored in your DB?
from cube.js.
@paveltiunov Excactly 👍
from cube.js.
@paveltiunov I think it would kind of solve the problem, however result in more complexity as we would have to recreate the schema dynamically by crawling through all chart configs whenever the configuration of a customer changes.
Is it very complicated to implement? I know that is very simple to add a custom dimension in a MySQL query: SELECT DAYNAME(createdAt) as 'createdAtWeekDay' [...]
But then I am not familiar with the architecture of cube.js 😃
from cube.js.
@gizmodus it should be as simple as providing hash for your current configuration state:
CubejsServerCore.create({
schemaVersion: () => sha1(JSON.stringify(config))
})
If schemaVersion
changes recompile will be issued.
Does it solve your problem?
from cube.js.
Are you going to add schemaVersion
soon? or is it already in CubejsServerCore config?
from cube.js.
@Kylia669 just added. Will be shipped in 0.3.5.
from cube.js.
Related Issues (20)
- Creare possbility to connect to Dremio Cloud Driver HOT 2
- Minimum permission policy for AWS S3 HOT 2
- I cant find openapi schema for cubejs, can we add it? HOT 2
- Sample for Cubejs QuestDB integration is out dated
- Support selection for the DATE_TRUNC function HOT 1
- [Feature request] Pre-aggregation within window
- Pre-Aggregations HOT 2
- [Feature request] make cubejs as datasouce of DB-GPT HOT 2
- (Rolling window?) aggregate generates invalid BQ SQL (Unexpected keyword WITH) HOT 1
- Cubestore AWS Credentials required HOT 2
- Addition of SQL_ALIAS property to Dimension/Measure HOT 1
- SQL Error with metabase
- Unable to use cubejs Vue client in Typescript component
- schema-compiler dependency (luxon) update HOT 3
- Migrate away from `request` and `request-promise` HOT 2
- Identical measures behave differently: one causes "Unrecognized name" error in generated SQL for BigQuery
- Preaggregations are not working from Metabase HOT 5
- cubejs/cube:v0.35.11 results in Model files not found errors HOT 1
- AWS S3 error in Cubestore after upgrading to 0.35 HOT 1
- Metabase SQL API doesn't use pre-aggregation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cube.js.