cube icon indicating copy to clipboard operation
cube copied to clipboard

Problem with “Polymorphic cubes”

Open thePermission opened this issue 3 months ago • 3 comments

Hey Guys, i try to follow: https://cube.dev/docs/product/data-modeling/concepts/polymorphic-cubes and https://cube.dev/docs/product/data-modeling/concepts/code-reusability-extending-cubes

But i get the feeling there is some issue with defining sql and sql table With a Cube like this:

cubes:
  - name: users
    sql_table: users

i cant write cubes like this:

cubes:
  - name: teachers
    extends: users
    sql: >
      SELECT * FROM {users.sql()} WHERE type = 'teacher'
 
  - name: students
    extends: users
    sql: >
      SELECT * FROM {users.sql()} WHERE type = 'student'

it will cause the error You must use either sql or sqlTable within a model, but not both

thePermission avatar Mar 14 '24 12:03 thePermission

Hi @thePermission 👋

As the error suggests, you'd have to use sql instead of sql_table in the users cube. Could you please try that?

igorlukanin avatar Mar 20 '24 15:03 igorlukanin

@thePermission Did my advice help?

igorlukanin avatar May 14 '24 10:05 igorlukanin

@igorlukanin Yea but the documentation is wrong then.

thePermission avatar May 14 '24 11:05 thePermission