Skip to content

[doc](sql-functions) Document nonnegative bitmap_union_int inputs - #4154

Open
HappenLee wants to merge 1 commit into
masterfrom
happenlee-bitmap-union-int-negative-values
Open

HappenLee wants to merge 1 commit into
masterfrom
happenlee-bitmap-union-int-negative-values

Conversation

@HappenLee

@HappenLee HappenLee commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Update the English and Chinese development-version documentation for BITMAP_UNION_INT to match the companion BE change apache/doris#68219 that ignores negative integer inputs.

Explain the nonnegative COUNT(DISTINCT CASE ...) equivalence, NULL/empty-group behavior, BIGINT return type, and mixed/all-invalid examples. Note the behavior difference from earlier releases. The 4.x and 3.x pages intentionally retain their released behavior; this is a version-specific exception to the synchronization check. Merge this documentation with or after the companion code fix.

Validation:

  • SQL-function documentation lint and changed-file link lint: passed.
  • English/Chinese content checked together; i18n lint reports only the intentional current/4.x difference.
  • SQL examples describe the new semantics; they were not executed against a patched cluster locally.

No page paths, navigation, function signatures or site code are changed.

Explain negative and NULL filtering, nonnegative distinct-count equivalence,
and empty-group behavior in both development-version locales. Keep released
version pages unchanged and document the upgrade behavior difference.

Validation: SQL-function documentation and changed-file link lint passed.
HappenLee added a commit to apache/doris that referenced this pull request Sep 21, 2026
`bitmap_agg` and `bitmap_union_int` currently pass signed negative
integers into `BitmapValue`, which converts them to unsigned bitmap
members. For example, `bitmap_agg(-1)` can contain
`18446744073709551615` and `bitmap_union_int(-1)` returns 1, while
`to_bitmap(-1)` produces an empty bitmap.

Filter negative integers before insertion in both aggregates. Cover
scalar insertion, nullable and non-nullable `bitmap_agg` batches, and
the integer-only branch of the shared bitmap-count aggregate. Preserve
the allocation-free batch path for all-nonnegative input and use a
tracked temporary buffer for filtered batches. Generic bitmap operations
and the full uint64 domain of `bitmap_union_count` are unchanged.

With this change:
- `bitmap_count(bitmap_agg(-1))` and `bitmap_union_int(-1)` return 0.
- Input `[-1, 0, 1, 1, NULL]` contributes exactly the members `{0, 1}`.
- All-negative/all-NULL groups produce an empty bitmap or a count of 0.

### Release note

`bitmap_agg` and `bitmap_union_int` now ignore negative integers,
consistently with `to_bitmap`. In particular, `bitmap_union_int` counts
distinct nonnegative integers rather than all distinct integers. Queries
containing negative inputs can return smaller counts after upgrading.

### Check List (For Author)

- Test: add BE unit tests covering TINYINT/SMALLINT/INT/BIGINT,
nullable/non-nullable input, negative minima, positive maxima, zero,
duplicates, all-negative/all-NULL groups, dense batches, reset,
streaming serialization and column merge paths. Also protect UINT64_MAX
in `bitmap_union_count`.
- Passed: clang-format 16 check, BE build-hygiene checks and `git diff
--check`.
- Passed: compiler syntax checks of both aggregate
registration/instantiation translation units and the modified test
translation unit, using the generated ASAN-UT compilation settings.
- Attempted: `run-be-ut.sh -j48 --run
--filter='BitmapIntegerAggregateTest.*:AggBitmapTest.*'`. The build
stops in unchanged `common/cpp/aws_common.cpp` because the local
thirdparty installation lacks
`aws/core/auth/GeneralHTTPCredentialsProvider.h`; tests have not
executed locally.
- Attempted: repository clang-tidy script. Analysis is blocked by an
existing unmatched NOLINTEND in `core/types.h` and existing warnings in
the touched files outside the new logic. No clean clang-tidy run is
claimed.
- Behavior changed: Yes, negative integers no longer contribute bitmap
members or counts. NULL handling, result types, function signatures and
intermediate/storage formats remain unchanged.
- Does this need documentation: Yes:
apache/doris-website#4154 updates the
English/Chinese development-version documentation and clarifies the
changed `bitmap_union_int` semantics.

### Review notes

The existing aggregate test helper exercises the batch, streaming and
merge paths without adding a new framework. Grouped additions use the
same scalar `add` entry point. No new locks, configuration, persistence
changes or FE/BE fields are introduced. Filtering is applied only to
integer inputs; already-materialized bitmaps are preserved. During a
rolling upgrade, old BEs can still contribute old partial states, so
uniform negative-input semantics require all executing BEs to contain
this fix.
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