Skip to content

Generated SQL for simple metrics in not correct #22

@SebZbp

Description

@SebZbp

Count_distinct aggregations are not generated properly.

Example

models:
  - name: test
    table: (SELECT 1 as id, 100 as value)
    primary_key: id
    metrics:
      - name: total
        agg: sum
        sql: value
  - name: location
    table: LOCKERS_AGGREGATION__DEV.METRICS.DIM_LOCATION
    primary_key: sk_location_id
    metrics:
      - name: count
        agg: count_distinct

generates for location.count

WITH location_cte AS (
  SELECT
    sk_location_id AS sk_location_id,
    count AS count_raw
  FROM LOCKERS_AGGREGATION__DEV.METRICS.DIM_LOCATION
)
SELECT
  COUNT(DISTINCT location_cte.count_raw) AS count
FROM location_cte
-- sidemantic: models=location metrics=location.count dimensions=

and count does not exist in the table

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