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

953 - Adding possibility of using "countDistinct" in aggregation #1027

Merged

Conversation

piotrkosecki
Copy link
Contributor

@piotrkosecki piotrkosecki commented Aug 9, 2021

This is a draft which possibly resolves #953

It introduces change which adds possibility of using distinct with aggregation functions.

Example query can look like that:

{
	"fields": ["meta_voting_period", "meta_cycle", "level"],
	"predicates": [{
		"field": "timestamp",
		"operation": "after",
		"set": [1577854800000],
		"inverse": false
	}],
	"orderBy": [{
		"field": "meta_voting_period",
		"direction": "desc"
	}],
	"aggregation": [{
		"field": "meta_cycle",
		"function": "countDistinct"
	}, {
		"field": "level",
		"function": "count"
	}],
	"limit": 1000
}

@piotrkosecki piotrkosecki changed the title 953 - Adding possibility of using "distinct" in the aggregation 953 - Adding possibility of using "distinctCount" in aggregation Aug 12, 2021
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@piotrkosecki piotrkosecki changed the title 953 - Adding possibility of using "distinctCount" in aggregation 953 - Adding possibility of using "countDistinct" in aggregation Aug 12, 2021
@piotrkosecki piotrkosecki marked this pull request as ready for review August 12, 2021 16:24
@vishakh
Copy link
Contributor

vishakh commented Sep 14, 2021

Please add an example to the tutorial on the Github wiki.

@@ -95,7 +96,10 @@ case class BigMapsOperations[Profile <: ExPostgresProfile](profile: Profile) ext
DBIO.sequence {
List(
Tables.BigMapContents.insertOrUpdateAll(rowsToWrite),
Tables.BigMapContentsHistory ++= updateData.map(Tables.BigMapContentsHistoryRow.tupled).distinct
Tables.BigMapContentsHistory ++= updateData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: This fixes a compilation issue.

@vishakh vishakh merged commit 2d45895 into master Sep 14, 2021
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

Successfully merging this pull request may close these issues.

Aggregations across multiple columns don't work
2 participants