Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregation Store: Fact to Fact Joins Not Aggregating metrics on Right Side of the Join #1955

Open
moizarafat opened this issue Mar 24, 2021 · 0 comments

Comments

@moizarafat
Copy link
Collaborator

When doing a Fact to Fact join the query generated is not correct for the right side of the join.

Expected Behavior

A Subquery representing the right side of the join should be created which will aggregate the measure before being used in the query.

Current Behavior

The Right Side of join is treated as a simple Dimension with no subquery/aggregation.

Steps to Reproduce (for bugs)

In elide-spring-boot-example, change the HJSON as below and try to hit the /downloads API.

{
    tables: [
    {
        name: downloads
        table: downloads
        description:
        '''
        Analytics for artifact downloads.
        '''
        joins: [
            {
                name: artifactGroup
                to: group
                kind: toOne
                definition: '{{group_id}} = {{artifactGroup.name}}'
            },
            {
                name: artifactProduct
                to: product
                kind: toOne
                definition: '{{product_id}} = {{artifactProduct.name}}'
            },
            {
                name: downloadsJoin
                to: downloadsNew
                kind: toOne
                definition: '{{group}} = {{downloadsJoin.group}} AND {{product}} = {{downloadsJoin.product}} AND {{date}} = {{downloadsJoin.date}}'
            },
        ]
        dimensions: [
            {
                name: group
                type: TEXT
                definition: '{{artifactGroup.name}}'
            }
            {
                name: product
                type: TEXT
                definition: '{{artifactProduct.name}}'
            }
            {
                name: date
                type: TIME
                definition: '{{date}}'
                grains: [
                    {
                        type: DAY
                    }
                ]
            }
        ]
        measures: [
            {
                name: downloads
                type: INTEGER
                definition: 'SUM({{downloads}})'
            }
            {
                name: downloadsReplicate
                type: INTEGER
                definition: 'SUM({{downloadsJoin.downloads}})'
            }
        ]
    },
    {
        name: downloadsNew
        table: downloads
        description:
        '''
        Analytics for artifact downloads.
        '''
        joins: [
            {
                name: artifactGroup
                to: group
                kind: toOne
                definition: '{{group_id}} = {{artifactGroup.name}}'
            },
            {
                name: artifactProduct
                to: product
                kind: toOne
                definition: '{{product_id}} = {{artifactProduct.name}}'
            }
        ]
        dimensions: [
            {
                name: group
                type: TEXT
                definition: '{{artifactGroup.name}}'
            }
            {
                name: product
                type: TEXT
                definition: '{{artifactProduct.name}}'
            }
            {
                name: date
                type: TIME
                definition: '{{date}}'
                grains: [
                    {
                        type: DAY
                    }
                ]
            }
        ]
        measures: [
            {
                name: downloads
                type: INTEGER
                definition: 'SUM({{downloads}})'
            }
        ]
    }
    ]
}

Context

Fact to Fact joins are very critical for our use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant