cube-js / cube-js/cube

Views: prefix:true conflict check runs on raw names when using explicit includes list

Open
#10,520 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

## Bug Description

When using `prefix: true` with an explicit `includes` list in a view definition, Cube incorrectly raises a member conflict error even though the final exposed member names would be unique after prefixing.

## Steps to Reproduce

Given three cubes:
- `orders` (has `count`, `total_revenue`, `status`, `order_date`)
- `customers` (has `count`, `name`, `region`, `tier`) — joined via `orders`
- `products` (has `count`, `name`, `category`) — joined via `order_items`

The following view definition **fails**:

```yaml
views:
- name: sales_overview
cubes:
- join_path: orders
includes:
- count
- total_revenue
- order_date
- status

- join_path: orders.customers
prefix: true
includes:
- name # would be exposed as customers_name
- region

- join_path: order_items.products
prefix: true
includes:
- name # would be exposed as products_name
- category
```

**Error:**
```
sales_overview cube: Included member 'name' conflicts with existing member of 'sales_overview'.
sales_overview cube: Included member 'count' conflicts with existing member of 'sales_overview'.
```

The following view definition **succeeds** (identical semantics, only `includes: "*"` + `excludes`):

```yaml
views:
- name: sales_overview
cubes:
- join_path: orders
includes: "*"

- join_path: orders.customers
prefix: true
includes: "*"

- join_path: order_items.products
prefix: true
includes: "*"
```

## Root Cause

When `includes` is given as an explicit list, the conflict check appears to run against raw member names **before** `prefix` is applied. When `includes: "*"` is used, the prefix is applied first, so `customers_name` and `products_name` are correctly treated as distinct members.

## Expected Behavior

`prefix: true` should be applied before the conflict check regardless of whether `includes` is a list or `"*"`. The following should work without errors:

```yaml
- join_path: orders.customers
prefix: true
includes:
- name # exposed as customers_name — no conflict
- region
```

## Environment

- Cube version: 1.6.23
- Database: PostgreSQL 14

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.