Skip to content

(cubes[1].includes = () => '*') must be one of [*, array] #9410

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

Open
AndreasTA-AW opened this issue Apr 1, 2025 · 1 comment
Open

(cubes[1].includes = () => '*') must be one of [*, array] #9410

AndreasTA-AW opened this issue Apr 1, 2025 · 1 comment
Assignees
Labels
question The issue is a question. Please use Stack Overflow for questions.

Comments

@AndreasTA-AW
Copy link

Describe the bug
While trying to generate dynamic models I get a weird error when generating the views:

Error: Error: Compile errors:
xxxxxxxxx cube: (cubes[1].includes = () => '*') must be one of [*, array]

But! The include is set like below, so it doesn't make sense, I can't remove the function that someone else is generating behind the scene?
includes: *,

To Reproduce
Steps to reproduce the behavior:

I'm reading a DBT yaml file, generating cubes and views from this.
When adding the views with multiple cubes I get this error. It says that join_path has to be a function, and that works.

Expected behavior
Well, I'm not making it a function and if it should not be a function I'm not sure how I should type it to work. I want it to compile and show my views/cubes.

dps = [
   {
       view: "some_name",
      name: "some_cube_name",
      joins: [
        {
            name: "another_cube_joined"
        }
      ]
  }
]

dps.forEach((dp) => {
    view(dp.view, {
      cubes: [
        {
          join_path: () => dp.name,
          includes: `*`,
        },
      ].concat(
        dp.joins?.map((j) => ({
          join_path: () => `${dp.name}.${j.name}`,
          includes: `*`,
          prefix: true,
        })) ?? []
      ),
    });
  });

Version:
1.2.27

@igorlukanin
Copy link
Member

igorlukanin commented Apr 14, 2025

Hi @AndreasTA-AW 👋

Here's how you can do it:

dps = [
  {
      view: "some_name",
     name: "some_cube_name",
     joins: [
       {
           name: "another_cube_joined"
       }
     ]
 }
]

cube(`some_cube_name`, {
 sql: `SELECT 123`,

 joins: {
   another_cube_joined: {
     sql: `1 = 1`,
     relationship: `one_to_one`
   }
 },

 dimensions: {
   id: {
     sql: `1`,
     type: `number`,
     primary_key: true
   }
 },

 measures: {
   count: {
     type: `count`
   },
   count_2: {
     type: `count`
   }
 }
})

cube(`another_cube_joined`, {
 sql: `SELECT 123`,

 dimensions: {
   id: {
     sql: `1`,
     type: `number`,
     primary_key: true
   }
 },

 measures: {
   count: {
     type: `count`
   },
   count_2: {
     type: `count`
   }
 }
})

 dps.forEach((dp) => {
  // Move the `cubes` list out of the view definition
  let cubes = [
    {
      join_path: () => dp.name,
      includes: `*`,
    },
  ].concat(
    dp.joins?.map((j) => ({
      join_path: () => `${dp.name}.${j.name}`,
      includes: `*`,
      prefix: true,
    })) ?? []
  )
  
   view(dp.view, {
     cubes
   });
 });

Please see what I've done with the cubes list.

Image

If you don't want to be hacking around JavaScript transpilation in Cube, consider using YAML syntax and Jinja for data models.

I hope it helps.

@igorlukanin igorlukanin self-assigned this Apr 14, 2025
@igorlukanin igorlukanin added the question The issue is a question. Please use Stack Overflow for questions. label Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question The issue is a question. Please use Stack Overflow for questions.
Projects
None yet
Development

No branches or pull requests

2 participants