Skip to content

Measure with string type, ends up with SUM aggregation in the generated SQL to pre-aggregations #9462

Open
@kevinleeTCA

Description

@kevinleeTCA

To Reproduce
This is my cube definition, but you can try this with any string/text based columns:

cube(`LE_LegalEntitiesMetadata`, {
    sql: `select * from data_export.legal_entities_metadata`,

    public: false,

    preAggregations: {
        rollup: {
            dimensions: [
                CUBE.legal_entity_id,
            ],
            measures: [
                CUBE.display_names
            ],
            indexes: {
                idx: {
                    columns: [CUBE.legal_entity_id]
                }
            },
            refresh_key: {
                every: `1 hour`,
            }
        }
    },


measures: {
        display_names: {
            sql: `STRING_AGG(${CUBE.display_name}::TEXT, ', ')`,
            type: `string`,
            title: `Investors/Company owners`
        }
    },

    dimensions: {
        legal_entity_id: {
            sql: `legal_entity_id`,
            type: `string`,
            primary_key: true,
            shown: true
        },
        entity_type: {
            sql: `entity_type`,
            type: `string`,
        },
        display_name: {
            sql: `display_name`,
            type: `string`,
            title: `Investors/Company owners`
        }
    },

    dataSource: `legal_entity`
});

I am using STRING_AGG measure, but the query:

{
  "dimensions": [
    "LE_LegalEntitiesMetadata.legal_entity_id"
  ],
  "measures": [
    "LE_LegalEntitiesMetadata.display_names"
  ]
}

ends up using sum in the generated SQL:

SELECT
  `l_e__legal_entities_metadata__legal_entity_id` `l_e__legal_entities_metadata__legal_entity_id`,
  sum(`l_e__legal_entities_metadata__display_names`) `l_e__legal_entities_metadata__display_names`
FROM
  dev_pre_aggregations.l_e__legal_entities_metadata_rollup AS `l_e__legal_entities_metadata__rollup`
GROUP BY
  1
ORDER BY
  2 DESC
LIMIT
  10000

Image
Image

Expected behavior
It should remain as STRING_AGG

  STRING_AGG(
    "l_e__legal_entities_metadata".display_name :: TEXT,
    ', '
  ) "l_e__legal_entities_metadata__display_names"

Version:
1.1.18

Metadata

Metadata

Assignees

Labels

pre-aggregationsIssues related to pre-aggregations

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions