How to create the data model without using sisense cli in my application using compose sdk
from the compose sdk tutorial above, the datamodel can be get by running cli. How do I achieve this dynamically in my application without running the cli? is there any sisense rest api can do this?
I'm getting the DM for building the data visualization as the tutorial provided here: https://www.sisense.com/blog/take-control-of-your-data-visualizations/
enmiwong
Posted 2 years ago · Edited 2 years ago·Last reply 2 years ago
2 comments
bogdan-karlenko
·2 years agoTo address your API request specifically, `sdk-cli` package uses `/api/datasources/<datasource_name>/fields/search` endpoint to grab initial datasource information which is then converted to attributes:
https://github.com/sisense/compose-sdk-monorepo/blob/main/packages/sdk-query-client/src/query-api-dispatcher/query-api-dispatcher.ts#L26
Note: using this endpoint will not give the final result as `sdk-cli` will, some additional code transformations will be required. `createAttribute` mentioned earlier is one of the tools that would help
steve
·2 years agoHi enmiwong
You can use Compose SDK without generating a datamodel by dynamically creating 'attributes' using createAttribute in your code. (you'll need to import this from sdk-data)
The minimum needed is the name and expression properties, and depending on the column type you might want more control e.g. granularity and format for date columns.
Expression is a string that consists of the name of the table and column, separated by a period, and enclosed in square brackets as shown below.
Example of creating a date dimension:
For more information, check this link to the docs.
Hope that helps!