Skip to content

Docs "getting started": users.USER_ID vs. users.ID #7286

@bbrewington

Description

@bbrewington

Glad to submit a PR for this to close out this issue, but just wanted to submit problem details I just discovered while walking through the tutorial here: https://cube.dev/docs/product/getting-started/cloud/create-data-model

Problem Details

USER_ID is used in the CREATE TABLE statement, but not in COPY INTO (see lines 80 & 94)

```sql
CREATE TABLE cube_demo.ecom.users
( id INTEGER,
user_id INTEGER,
city VARCHAR,
age INTEGER,
gender VARCHAR,
state VARCHAR,
first_name VARCHAR,
last_name VARCHAR,
created_at TIMESTAMP
);
```

COPY INTO cube_demo.ecom.users (id, city, age, gender, state, first_name, last_name, created_at)

YAML should reference {users}.ID instead of {users}.USER_ID (lines 66 & 140)

cubes:
- name: orders
sql_table: ECOM.ORDERS
joins:
- name: users
sql: "{CUBE}.USER_ID = {users}.USER_ID"
relationship: many_to_one

cubes:
- name: orders
sql_table: ECOM.ORDERS
joins:
- name: users
sql: "{CUBE}.USER_ID = {users}.USER_ID"
relationship: many_to_one

Additional Info

Ran this query after importing data from AWS S3 bucket as laid out in the tutorial:

SELECT
    'JOIN ON USERS.ID' as LABEL,
    SUM(IFF("users".ID IS NULL, 1, 0)) as NUM_NULL,
    COUNT(*) as NUM_RECORDS
FROM CUBE_DEMO_ECOM.ORDERS AS "orders"
LEFT JOIN CUBE_DEMO_ECOM.USERS AS "users"
    ON "orders".USER_ID = "users".ID

UNION ALL

SELECT
    'JOIN ON USERS.USER_ID' as LABEL,
    SUM(IFF("users".USER_ID IS NULL, 1, 0)) as NUM_NULL,
    COUNT(*) as NUM_RECORDS
FROM CUBE_DEMO_ECOM.ORDERS AS "orders"
LEFT JOIN CUBE_DEMO_ECOM.USERS AS "users"
    ON "orders".USER_ID = "users".USER_ID

Results:

LABEL NUM_NOT_NULL NUM_RECORDS
JOIN ON USERS.ID 10000 10000
JOIN ON USERS.USER_ID 0 10000

Metadata

Metadata

Assignees

Labels

docsIssues that require a documentation improvement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions