cube icon indicating copy to clipboard operation
cube copied to clipboard

`prefix` or `public` keys break `meta`

Open igorlukanin opened this issue 1 year ago • 1 comments
trafficstars

Describe the bug This data model file compiles successfully:

cubes:
  - name: meta_prefix
    sql: SELECT 123

    measures:
      - name: count
        type: count
        meta: 
          my_prefix: qwerty

However, the following data model file would not compile (take a close look at meta):

cubes:
  - name: meta_prefix
    sql: SELECT 123

    measures:
      - name: count
        type: count
        meta: 
          prefix: qwerty

It emits the following error:

cubes/meta_prefix.yml:8
        "prefix": qwerty
                  ^

ReferenceError: qwerty is not defined
    at cubes/meta_prefix.yml:8:19
    at Script.runInContext (node:vm:133:12)
    at Script.runInNewContext (node:vm:138:17)
    at Object.runInNewContext (node:vm:290:38)
    at DataSchemaCompiler.compileJsFile (/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:256:10)
    at /node_modules/@cubejs-backend/schema-compiler/src/compiler/YamlCompiler.ts:101:36
    at Array.forEach (<anonymous>)
    at YamlCompiler.compileYamlFile (/node_modules/@cubejs-backend/schema-compiler/src/compiler/YamlCompiler.ts:99:31)
    at DataSchemaCompiler.compileFile (/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:245:25)
    at /node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:195:14

Apparently, there's an issue with data model validation: prefix is not accepted inside meta if it has a value of the string type. Passing a boolean or a numeric value works.

Might be related to how Cube validates prefix inside views (docs).

Expected behavior It should be allowed to use prefix inside meta on cube/view members.

Version: 0.35.45

Additional context Reported in Slack: https://cube-js.slack.com/archives/C04NYBJP7RQ/p1717591569187009

igorlukanin avatar Jun 07 '24 14:06 igorlukanin

Apparently, public also breaks meta in the same way.

igorlukanin avatar Jun 07 '24 14:06 igorlukanin

It seems that this might been already fixed. Just tried on the current (1.2.30) - got the expected results in meta without errors:

        {
            "name": "simple_orders",
            "type": "cube",
            "title": "Simple Orders",
            "isVisible": true,
            "public": true,
            "measures": [
                {
                    "name": "simple_orders.count",
                    "title": "Simple Orders Count",
                    "shortTitle": "Count",
                    "cumulativeTotal": false,
                    "cumulative": false,
                    "type": "number",
                    "aggType": "count",
                    "drillMembers": [],
                    "drillMembersGrouped": {
                        "measures": [],
                        "dimensions": []
                    },
                    "meta": {
                        "my_prefix_string": "qwerty",
                        "another_number": 123,
                        "another_boolean": true
                    },
                    "isVisible": true,
                    "public": true
                },

KSDaemon avatar Apr 07 '25 11:04 KSDaemon

So, I'm closing it for now.

KSDaemon avatar Apr 07 '25 11:04 KSDaemon