-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
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:
# cubes/applications.yml
{% set model = dbt_model('applications') %}
cubes:
- name: "cube_{{ model.name | safe }}"
sql: >
SELECT * FROM {{ model.sql_table | safe }}
public: false
dimensions:
{{ model.as_dimensions() }}
# Model-specific measures
measures:
- name: total_count
type: count# cubes/applications_sent.yml
cubes:
- name: cube_applications_sent
extends: cube_applications
sql: >
SELECT * FROM { cube_applications.sql() } WHERE applied_at is not null
public: falseAccording to the documentation, this could work, but it gives me the following error:
Error: Compile errors:
Can't parse python expression. Most likely this type of syntax isn't supported yet: Unsupported Python Trailer children node: TrailerContext: ()
at ErrorReporter.throwIfAny (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/ErrorReporter.ts:133:13)
at DataSchemaCompiler.throwIfAnyErrors (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:213:23)
at /cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:108:16
at CompilerApi.getCompilers (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:66:26)
at CompilerApi.scheduledPreAggregations (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:189:31)
at RefreshScheduler.roundRobinRefreshPreAggregationsQueryIterator (/cube/node_modules/@cubejs-backend/server-core/src/core/RefreshScheduler.ts:474:38)
at /cube/node_modules/@cubejs-backend/server-core/src/core/RefreshScheduler.ts:595:12
at async Promise.all (index 0)
If I modify the applications_sent cube's SQL to SELECT * FROM { cube_applications.sql } WHERE applied_at is not null then I can see that the cube_applications.sql is injected as a JS arrow function () = > query.cubeSql(cube.cubeName()) – obviously Python cannot evaluate it
Describe 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
# cubes/applications_sent.yml
{% set model = dbt_model('applications') %}
cubes:
- name: cube_applications_sent
extends: cube_applications
sql: >
SELECT * FROM {{ model.sql_table | safe }} WHERE applied_at is not null
public: false^ this will work but feels a bit hacky