Skip to content

Surface SUM and AVG on booleans as an error#1952

Merged
shangyian merged 3 commits intoDataJunction:mainfrom
shangyian:sum-bool
Apr 3, 2026
Merged

Surface SUM and AVG on booleans as an error#1952
shangyian merged 3 commits intoDataJunction:mainfrom
shangyian:sum-bool

Conversation

@shangyian
Copy link
Copy Markdown
Collaborator

@shangyian shangyian commented Apr 3, 2026

Summary

Both SUM(bool_type) and AVG(bool_type) in DJ should surface an error. Removing the BooleanType handler means that .infer_type(BooleanType) will now fall through and raise a TypeError/NotImplementedError, which gets caught during node compilation as a validation error.

Users will see a type mismatch and know to use CAST(expr AS BIGINT) or SUM(CASE WHEN expr THEN 1 ELSE 0 END) explicitly.

Test Plan

  • PR has an associated issue: #
  • make check passes
  • make test shows 100% unit test coverage

Deployment Plan

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 3, 2026

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit c961f36
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/69d0270d2bd0100008b44c25

@shangyian shangyian changed the title Remove boolean arguments for SUM Surface SUM on booleans as an error Apr 3, 2026
@shangyian shangyian changed the title Surface SUM on booleans as an error Surface SUM on booleans as an error Apr 3, 2026
@shangyian shangyian marked this pull request as ready for review April 3, 2026 20:12
@shangyian shangyian changed the title Surface SUM on booleans as an error Surface SUM and AVG on booleans as an error Apr 3, 2026
@shangyian shangyian merged commit d00b945 into DataJunction:main Apr 3, 2026
17 checks passed
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.

1 participant