Skip to content

prefix or public keys break meta #8335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
igorlukanin opened this issue Jun 7, 2024 · 3 comments
Closed

prefix or public keys break meta #8335

igorlukanin opened this issue Jun 7, 2024 · 3 comments
Assignees
Labels
bug Something isn't working data modeling

Comments

@igorlukanin
Copy link
Member

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
Copy link
Member Author

Apparently, public also breaks meta in the same way.

@igorlukanin igorlukanin changed the title prefix key breaks meta prefix or public keys break meta Jun 7, 2024
@KSDaemon KSDaemon assigned KSDaemon and unassigned paveltiunov Apr 7, 2025
@KSDaemon
Copy link
Member

KSDaemon commented Apr 7, 2025

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
Copy link
Member

KSDaemon commented Apr 7, 2025

So, I'm closing it for now.

@KSDaemon KSDaemon closed this as completed Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working data modeling
Projects
None yet
Development

No branches or pull requests

3 participants