Somewhere I want status=2 or status<3. Instead of writing separate schemas, how to reuse by passing dynamic values to the status field in SQL?
cube(`OrderFacts`, {
sql: `SELECT * FROM orders WHERE status>3`, // <--- I want to pass dynamic values to the condition
measures: {
count: {
type: `count`
}
},
dimensions: {
date: {
sql: `date`,
type: `time`
}
}
});
Please refer to the Unsafe Value section of the Context Variables documentation:
cube(`Orders`, {
sql: `SELECT * FROM orders WHERE status > ${SECURITY_CONTEXT.status.unsafeValue()`,
});
Generally speaking, it's best not to do this though; instead I'd recommend using segments to achieve the same functionality (assuming there aren't a lot of values for status
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.