Skip to content

multi_stage leaf measure throws "lacks FROM clause" when sql references raw column #10549

@TheRoot-1

Description

@TheRoot-1

Describe the bug

When a multi_stage measure's sql references a raw column (no {} measure dependency), and another multi_stage measure references it via {}, the query throws:

Multi stage member 'cube.measure' lacks FROM clause in sub query

To Reproduce

cubes:
  - name: orders
    sql_table: orders

    dimensions:
      - name: id
        sql: id
        type: number
        primary_key: true

      - name: status
        sql: status
        type: string

    measures:
      - name: raw_sum
        sql: amount
        type: sum
        multi_stage: true

      - name: computed
        sql: "{raw_sum}"
        type: number
        multi_stage: true

Query orders.computed with any dimension — the leaf measure raw_sum causes the error.

Root cause

In renderWithQuery (BaseQuery.js), the leaf measure has no children in the member dependency graph, so memberFrom is null. This makes fromMeasures null → fromSubQuery null → fromSql null. The error check at the end of renderWithQuery then throws because subQuery.from is undefined.

Expected behavior

The query should build successfully, falling back to querying the cube's own table when fromSubQuery was never built.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions