elide
elide copied to clipboard
Aggregation Store: Fact to Fact Joins Not Aggregating metrics on Right Side of the Join
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.