cube-js / cube

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

Cubes using sql_table cant be exented with sql #8519

Open thePermission opened 2 months ago

thePermission commented 2 months ago

Describe the bug Hey Guys, i tried 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 if you use sql_table in your base cube and sql in your extended cube, then u get the error: You must use either sql or sqlTable within a model, but not both

To Reproduce

  1. Create a Base Cube like this:
    cubes:
    - name: users
    sql_table: users
  2. Extend the Base Cube 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'

Expected behavior I would expect the sql attribute to overwrite the sql_table

igorlukanin commented 1 week ago

It makes sense to make he sql parameter to supersede the sql_table one. However, I think this is rather a feature request than a bug since a correct error message is provided by Cube now.