cube icon indicating copy to clipboard operation
cube copied to clipboard

`One or more Primary key is required for '${cubeName}' cube` error

Open Anger79 opened this issue 3 weeks ago • 1 comments

Describe the bug Since the last cubejs version update (0.33.53 -> 0.35.41) we started having a query that fails with "One or more Primary key is required for 'TestCube' cube" error. Query has "ungrouped": true. Cube doesn't have a primary key, pre-aggregations or joins. allowUngroupedWithoutPrimaryKey is set to true.

Query example

{
   "dimensions":[
      "TestCube.device_name",
      "TestCube.device_user",
      "TestCube.timestamp"
   ],
   "timeDimensions":[
      {
         "dimension":"TestCube.timestamp",
         "dateRange":[
            "2024-05-15T01:00:00.000",
            "2024-05-22T01:00:00.000"
         ]
      }
   ],
  "ungrouped": true,
  "offset": 0,
  "limit": 1000
}

Minimally reproducible Cube Schema Simple cube without pre-aggregations or joins:

cube (`TestCube`, {
    sql: `select * from test_table WHERE ${SECURITY_CONTEXT.account_id.filter('account_id')}`,
    dimensions: {
        device_name: {
            sql: `device_name`,
            type: `string`
        },
        user: {
            sql: `user`,
            type: `string`
        },
        timestamp: {
            sql: `timestamp`,
            type: `time`
        }
    }
})

Version: [0.35.41]

Anger79 avatar Jun 13 '24 14:06 Anger79