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

Make Numeric.sum return null when there are no inputs or all null inputs #5461

Merged
merged 2 commits into from
May 7, 2024

Conversation

chipkent
Copy link
Member

@chipkent chipkent commented May 7, 2024

Make Numeric.sum return null when there are no inputs or all null inputs. This makes the method consistent with the aggregations.

@chipkent chipkent added this to the 3. May 2024 milestone May 7, 2024
@chipkent chipkent self-assigned this May 7, 2024
@chipkent chipkent requested review from kosak and rcaudy as code owners May 7, 2024 20:39
@chipkent chipkent added bug Something isn't working query engine labels May 7, 2024
@@ -1488,6 +1488,7 @@ public class Numeric {
}

double sum = 0;
long nullCount = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to handle infinities the way aggBy does?

    private double currentValueWithSum(long totalNormalCount, long totalNanCount, long totalPositiveInfinityCount,
            long totalNegativeInfinityCount, double newSum) {
        if (totalNanCount > 0 || (totalPositiveInfinityCount > 0 && totalNegativeInfinityCount > 0)) {
            return Double.NaN;
        }
        if (totalNegativeInfinityCount > 0) {
            return Double.NEGATIVE_INFINITY;
        }
        if (totalPositiveInfinityCount > 0) {
            return Double.POSITIVE_INFINITY;
        }
        if (totalNormalCount == 0) {
            return QueryConstants.NULL_DOUBLE;
        }
        return (double) newSum;
    }

Copy link
Member Author

Choose a reason for hiding this comment

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

Larry and I had a discussion on this before the prior fix. It is unnecessary because of how IEEE754 does things. Look at the unit tests.

@chipkent chipkent enabled auto-merge (squash) May 7, 2024 21:07
@chipkent chipkent merged commit cd444b6 into deephaven:main May 7, 2024
15 checks passed
@chipkent chipkent deleted the sum_all_null branch May 7, 2024 21:22
@github-actions github-actions bot locked and limited conversation to collaborators May 7, 2024
@deephaven-internal
Copy link
Contributor

Labels indicate documentation is required. Issues for documentation have been opened:

Community: deephaven/deephaven-docs-community#207

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working DocumentationNeeded query engine ReleaseNotesNeeded Release notes are needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants