Yes, your understanding is correct. See the code
<https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/schema/Statistics.java#L79>
for the isKey() method:

@Override public boolean isKey(ImmutableBitSet columns) {
        for (ImmutableBitSet key : keysCopy) {
          if (columns.contains(key)) {
            return true;
          }
        }
        return false;
      }

If any key combination includes any of the key combinations of the list,
then it is a key.

On Fri, Feb 28, 2025 at 10:32 AM Ian Bertolacci
<[email protected]> wrote:

> Howdy,
> From Statistic.getKeys: Returns a list of unique keys, or null if no key
> exist.
> I’m not understanding why this is a list of bitsets.
> Is the idea that each entry in the list is a bitset of keys which are
> unique when used together?
> For example, lets say I have this table:
> C0 | C1 | C2
>  0 |  2 |  2
>  0 |  3 |  4
>  1 |  2 |  2
>  1 |  3 |  5
> None of these columns are individually unique, but when used together (C0,
> C1), and (C0, C2) form a unique set.
> So would this be described by the list: ImmutableList.of(
> ImmutableBitSet.of(0, 1), ImmutableBitSet.of(0, 2) ) ?
>
> Thanks!
>
>
>

Reply via email to