cube-js / cube

📊 Cube — The Semantic Layer for Building Data Applications
https://cube.dev
Other
17.84k stars 1.77k forks source link

Problem with “Polymorphic cubes” #7913

Open thePermission opened 7 months ago

thePermission commented 7 months ago

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

igorlukanin commented 6 months ago

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 commented 4 months ago

@thePermission Did my advice help?

thePermission commented 4 months ago

@igorlukanin Yea but the documentation is wrong then.