Closed danfaro closed 7 months ago
Hey @danfaro 👋
It could be one of three issue, my syntax is wrong, the syntax in the docs are wrong or cube is not handling js correctly. Let's see 😄
Here's how the join is defined in the code example in the docs:
joins:
- name: nested_agg_sales
sql: "{nested_agg_stores_orders.store_product_id} = {nested_agg_sales.store_product_id}"
relationship: one_to_many
As you can see, on both sides of SQL dimensions are referenced.
Here's how the join is defined in your code example:
joins: {
nested_agg_sales_js: {
relationship: `one_to_many`,
sql: `${CUBE}.store_product_id = ${nested_agg_sales_js.store_product_id}`,
},
},
As you can see, now you have a column reference on the left side of the join. If you update it back to a dimension reference, it should work again.
I hope this helps.
Thanks Igor, your suggestion worked to fix the data model. I changed the sql from ${CUBE}.store_product_id
to ${CUBE.store_product_id}
.
I was following the subquery dimensions documentation that uses the column reference without understanding the intricacies of the member syntax doc that you linked.
A related question: can I do multiple levels of nested aggregation? Cube1 -(Sum)-> Cube2 -(Avg)-> Cube3 -(Max)-> Cube4.
I tried to implement it, but got an error message that like this:
I think you should be able to do that. Every additional level of nested aggregation is just an auxiliary cube with the desired measure + a reference to it in a subquery dimension of a previous cube.
The error message looks like it was returned by the database. You might have an error in the SQL, maybe in the sql
of your auxiliary cubes. (You can always simplify and test with a "dummy" cube: sql
as SELECT 123
, join
on 1=1
.)
Describe the bug I'm trying to replicate the nested aggregation function using javascript https://cube.dev/docs/guides/recipes/data-modeling/nested-aggregates. However the page's sample code is only in YAML.
When I recreate the example nested aggregation data model in a JS file following the js syntax shown in (https://cube.dev/docs/product/data-modeling/concepts/subquery-dimensions), Cube reports the following error:
It could be one of three issue, my syntax is wrong, the syntax in the docs are wrong or cube is not handling js correctly. I've checked things repeated with the docs and I'm not able to see what I'm doing wrong.
To Reproduce Steps to reproduce the behavior: Recreate nested aggregation model in js file.
Expected behavior Be able to test in play ground without errors
Screenshots If applicable, add screenshots to help explain your problem.
Minimally reproducible Cube Schema In case your bug report is data modelling related please put your minimally reproducible Cube Schema here. You can use selects without tables in order to achieve that as follows.
Version: cube cloud
Additional context