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

Fix(DQL): Fix Aggregate Functions on empty data #7176

Merged
merged 3 commits into from
Jan 5, 2021
Merged

Conversation

vmrajas
Copy link
Contributor

@vmrajas vmrajas commented Dec 21, 2020

Motivation:
Currently, in case aggregate functions like avg, sum, min, max are queried on empty data, the float value 0.0 is returned. This is particularly annoying as even min/max on a string returns 0.0 . This PR fixes this and returns NULL instead.

Testing:

  1. Added e2e tests to graphql/common
  2. Added e2e tests to quer/query1_test.go

Fixes DGRAPH-2843


This change is Reviewable

Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

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

:lgtm: The commit description should say that this is a breaking change and what cases would be breaking i.e. a different result would be returned.

Reviewed 3 of 5 files at r1.
Reviewable status: 3 of 5 files reviewed, 1 unresolved discussion (waiting on @MichaelJCompton, @pawanrawal, and @vmrajas)


query/query.go, line 1723 at r1 (raw file):

	}

	if sg.DestUIDs.Size() > 0 {

len(sg.DestUIDs.GetUids()) > 0 would be a better check and is also O(1) as you are just getting the length of a slice

@vmrajas vmrajas merged commit 12d50d8 into master Jan 5, 2021
@vmrajas vmrajas deleted the DGRAPH-2843 branch January 5, 2021 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants