-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{cube.sql()} is not supported in YAML/Python #7484
Comments
Hey @wasd171 👋 Thanks for reporting this! My understanding is that |
Thanks for a swift answer @igorlukanin
But I need some table to |
As a workaround, I can recommend to put that table name in a variable, then use it in both cubes. In the meantime, we should definitely make |
Any news on {cube.sql()} issue? |
@ZiggiZagga Supporting this is on the roadmap, however, there's currently no estimate as to when this might be done. |
Hallo @igorlukanin, I am learning cube and how it works. I have now come across the concept of Data Blending: I am looking at the example: https://cube.dev/docs/product/data-modeling/concepts/data-blending cube(`all_sales`, {
sql: `
SELECT
amount,
user_id AS customer_id,
created_at,
'online' AS row_type
FROM (${online_orders.sql()}) AS online --source cube via literal template
UNION ALL
SELECT
amount,
customer_id,
created_at,
'retail' AS row_type
FROM (${retail_orders.sql()}) AS retail --source cube via literal template
`,
}); I was wondering isn't it more intuitiv if we had an addition property called "cube_sql" which works as follows cube(`all_sales`, {
-- new property "cube_sql"
cube_sql: `
SELECT
amount,
user_id AS customer_id,
created_at,
'online' AS row_type
FROM online_orders AS online --source cube via cube id
UNION ALL
SELECT
amount,
customer_id,
created_at,
'retail' AS row_type
FROM retail_orders AS retail --source cube via cube id
`,
}); this way, as a developer i dont need to call cube.sql() because it will be treated behind the scenes. All I need to do is refer to cubes by their identifiers. What do you think is this possible? |
Hi @ZiggiZagga, thanks for the code example! Frankly, I don't see it as an improvement over the current situation. First, it doesn't simplify the definition of data model: instead of Second, it introduces additional ambiguity: without checking which parameter is used, one can never be sure if I also doubt that bare |
Commenting to follow for updates, would love to see this feature work for |
+1 |
+1 to this! I just spent a decent amount of time trying to get this to work and posted in slack before finding out its not supported for yaml syntax.
@igorlukanin its fine if this isnt a top priority right now, understandable, but I might suggest adding a warning to the docs so users are aware that the data blending feature isnt fully supported for yaml yet. Maybe a link to this issue would be helpful too. |
@pnadolny13 Sorry for the confusion. I have added a couple more links to this issue to the docs. |
Thanks @igorlukanin! |
Is your feature request related to a problem? Please describe.
Extending cubes brings great code reusability. However, it is currently not supported for the Python cubes. Look at these 2 cubes:
According to the documentation, this could work, but it gives me the following error:
If I modify the
applications_sent
cube's SQL toSELECT * FROM { cube_applications.sql } WHERE applied_at is not null
then I can see that thecube_applications.sql
is injected as a JS arrow function() = > query.cubeSql(cube.cubeName())
– obviously Python cannot evaluate itDescribe the solution you'd like
I would like to be able to extend Python cubes the same way as it is possible for the YAML / JS ones
Describe alternatives you've considered
Since I am preparing my data in dbt I can refactor the
applications_sent
cube to^ this will work but feels a bit hacky
The text was updated successfully, but these errors were encountered: