cube-js / cube

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

Rollup Designer in Cube Core is broken for YAML data models #5989

Open dongchirua opened 1 year ago

dongchirua commented 1 year ago

Hi folks,

I had a question which I posted at https://forum.cube.dev/t/syntax-error-missing-semicolon-in-schema/598 and slack, regarding syntax error.

My schema file is

cubes:
  - name: AnalystProfiles
    sql: SELECT * FROM analyst_profiles
      # preAggregations:
      # Pre-Aggregations definitions go here
      # Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started
    joins: []
    measures:
      - name: count
        type: count
        drillMembers: [firstName, gender]
    dimensions:
      - name: age
        sql: age
        type: number
      - name: firstName
        sql: first_name
        type: string
      - name: gender
        sql: gender
        type: string
    dataSource: default

And error log is Syntax error during 'AnalystProfiles.yaml' parsing: Missing semicolon. (2:8): - name: AnalystProfiles ^

Basically, my schema file was generated by cube, but when I got an error that was confusing to me. I wonder if anyone here has ever encountered this?

FYI, I am using latest version with Docker

jasonyanwenl commented 1 year ago

I am facing the same issue even using the example yaml orders.yml. @dongchirua have you figured out this issue? Thank you!

torshind commented 1 year ago

This is the same for me. And this crashes cube as well:

cube_1           | Error: Cannot set headers after they are sent to the client
cube_1           |     at new NodeError (node:internal/errors:387:5)
cube_1           |     at ServerResponse.setHeader (node:_http_outgoing:644:11)
cube_1           |     at ServerResponse.header (/cube/node_modules/express/lib/response.js:771:10)
cube_1           |     at ServerResponse.send (/cube/node_modules/express/lib/response.js:170:12)
cube_1           |     at ServerResponse.json (/cube/node_modules/express/lib/response.js:267:15)
cube_1           |     at /cube/node_modules/@cubejs-backend/server-core/src/core/DevServer.ts:581:11
cube_1           |     at /cube/node_modules/@cubejs-backend/server-core/src/core/DevServer.ts:78:9
cube_1           | Error: Cannot set headers after they are sent to the client
cube_1           |     at new NodeError (node:internal/errors:387:5)
cube_1           |     at ServerResponse.setHeader (node:_http_outgoing:644:11)
cube_1           |     at ServerResponse.header (/cube/node_modules/express/lib/response.js:771:10)
cube_1           |     at ServerResponse.send (/cube/node_modules/express/lib/response.js:170:12)
cube_1           |     at ServerResponse.json (/cube/node_modules/express/lib/response.js:267:15)
cube_1           |     at /cube/node_modules/@cubejs-backend/server-core/src/core/DevServer.ts:82:25

My cube:

cubes:
  - name: c1_b1_raw_adult
    sql_table: c1.c1_b1_raw_adult
    data_source: default

    pre_aggregations:
      # Pre-aggregation definitions go here
      # Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started

    joins: []

    measures:
      - name: count
        type: count

    dimensions:
      - name: age
        sql: age
        type: number

Proposed pre-aggregation:

name: main
measures:
  - c1_b1_raw_adult.count
dimensions:
  - c1_b1_raw_adult.age

Can happen because the model files is on a docker volume owned by a user on the host?

Cube v0.33.2

P-Arnold commented 1 year ago

Hi, I'm also facing the same issue. Was anyone able to work it out?

josephybh commented 1 year ago

Any update?

igorlukanin commented 1 year ago

Hey @josephybh @P-Arnold and everyone 👋

Which version of Cube are you using? Could you please try upgrading to the latest one?

I've checked this very source code with Cube v0.34 and it compiles and works perfectly for me:

cubes:
  - name: AnalystProfiles
    sql: SELECT * FROM analyst_profiles
      # preAggregations:
      # Pre-Aggregations definitions go here
      # Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started
    joins: []
    measures:
      - name: count
        type: count
        drillMembers: [firstName, gender]
    dimensions:
      - name: age
        sql: age
        type: number
      - name: firstName
        sql: first_name
        type: string
      - name: gender
        sql: gender
        type: string
    dataSource: default
GomesNayagam commented 1 year ago

i use the same v0.34 it is not working either

documentation is outdated, i manually configured this works. or it could be UI or api issues.

https://cube.dev/docs/reference/data-model/pre-aggregations

pre_aggregations:
  - name: orders_by_status
    dimensions:
      - CUBE.status
    measures:
      - CUBE.count
github-actions[bot] commented 10 months ago

If you are interested in working on this issue, please leave a comment below and we will be happy to assign the issue to you. If this is the first time you are contributing a Pull Request to Cube.js, please check our contribution guidelines. You can also post any questions while contributing in the #contributors channel in the Cube.js Slack.

yb9255 commented 10 months ago

Hi guys, I also faced the same issue in v0.34.42 while I was following cube core tutorial. I even tried to use js format for data models, I still ran into parsing error because of example_view.yml.

whtblktone commented 5 months ago

Any update ?

igorlukanin commented 1 month ago

I was able to reproduce this on Cube Core v0.36.2. It looks like the Rollup designer there incorrectly detects data model file format. It initially suggests JavaScript even though my data model is in YAML:

Screenshot 2024-10-09 at 01 56 17

When I manually switched it to YAML and tried to add the rollup, the following error occurred:

Screenshot 2024-10-09 at 01 56 32

However, when I try the same steps in Cube Cloud, it correctly detects data model file format and sets it to YAML automatically. Data model that I used:

cubes:
  - name: AnalystProfiles
    sql: SELECT 123 AS age, 'John' AS first_name, 'male' AS gender
      # preAggregations:
      # Pre-Aggregations definitions go here
      # Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started
    joins: []
    measures:
      - name: count
        type: count
        drillMembers: [firstName, gender]
    dimensions:
      - name: age
        sql: age
        type: number
      - name: firstName
        sql: first_name
        type: string
      - name: gender
        sql: gender
        type: string
    dataSource: default