Skip to content

type:number_agg seems to not be working #10799

@michofwood

Description

@michofwood

Trying to use number_agg instead of number cause problems with this dense_rank()

    count: {
      type: `count`,
    },
    count_rank: {
    multi_stage: true,
    type: `number`,
    sql: `DENSE_RANK() OVER (ORDER BY ${count} DESC)`
    },

vs

    count: {
      type: `count`,
    },
    count_rank: {
    multi_stage: true,
    type: `number_agg`,
    sql: `DENSE_RANK() OVER (ORDER BY ${count} DESC)`
    }

Gives me
```ER_PARSE_ERROR: Getting analyzing error from line 16, column 69 to line 16, column 132. Detail message: 'dense_rank() OVER (ORDER BY fk_aggregate.`orders__count` DESC)' must be an aggregate expression or appear in GROUP BY clause.

on the sample cube
```cube(`Orders`, {
  sql: `
  select 1 as id, 100 as amount, 'new' status
  UNION ALL
  select 2 as id, 200 as amount, 'new' status
  UNION ALL
  select 3 as id, 300 as amount, 'processed' status
  UNION ALL
  select 4 as id, 500 as amount, 'processed' status
  UNION ALL
  select 5 as id, 600 as amount, 'shipped' status
  `,
  measures: {
    count: {
      type: `count`,
    },
    count_rank: {
    multi_stage: true,
    type: `number_agg`,
    sql: `DENSE_RANK() OVER (ORDER BY ${count} DESC)`
    },

    totalAmount: {
      sql: `amount`,
      type: `sum`,
    },
    toRemove: {
      type: `count`,
    },
  },
  dimensions: {
    status: {
      sql: `status`,
      type: `string`,
    },
  },
});

And on my posgresql (starrocks) gives

ER_PARSE_ERROR: Getting analyzing error from line 51, column 385 to line 51, column 495. Detail message: No matching function with signature: numberagg(bigint(20)).

As the SQL sent has

	numberAgg(numberAgg(DENSE_RANK() OVER (ORDER BY `fk_aggregate`.`xyx` DESC))) OVER (PARTITION BY `fk_aggregate`.`xxx`,
(...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions