I think so:
 /** Returns a list of unique keys, or null if no key exist. */
is the javadoc for getKeys(). Maybe the javadoc could be improved to make
that clear, that if there is no unique key, it must return null, not an
empty BitSet.

On Fri, Feb 28, 2025 at 2:54 PM Ian Bertolacci
<ian.bertola...@workday.com.invalid> wrote:

> Thanks!
> One thing I’ve noticed (in my short time using this) is that if I provide
> the a list with the empty set, it seems to consider *all* columns as unique.
> I observe this AggregateRemoveRule, where no matter what field I used to
> group by it removes the aggregate if the aggregations allow it.
> Is that expected?
>
> From: Steven Phillips <ste...@dremio.com.INVALID>
> Reply-To: "dev@calcite.apache.org" <dev@calcite.apache.org>
> Date: Friday, February 28, 2025 at 10:51
> To: "dev@calcite.apache.org" <dev@calcite.apache.org>
> Subject: Re: Understanding Statistic unique keys
>
> Yes, your understanding is correct. See the code <https: //urldefense.
> com/v3/__https: //github.
> com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/schema/Statistics.
> java*L79__;Iw!!Iz9xO38YGHZK!__IoxmI3k4LRQpWH1La5xkTnACIGx12YCEM-FiYbO59VwM4y4GsgNencLrOAO3Lg2KibvVHEtdQqmCB9UebWF2WRwg$>
>
>
> Yes, your understanding is correct. See the code
>
> <
> https://urldefense.com/v3/__https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/schema/Statistics.java*L79__;Iw!!Iz9xO38YGHZK!__IoxmI3k4LRQpWH1La5xkTnACIGx12YCEM-FiYbO59VwM4y4GsgNencLrOAO3Lg2KibvVHEtdQqmCB9UebWF2WRwg$
> <
> https://urldefense.com/v3/__https:/github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/schema/Statistics.java*L79__;Iw!!Iz9xO38YGHZK!__IoxmI3k4LRQpWH1La5xkTnACIGx12YCEM-FiYbO59VwM4y4GsgNencLrOAO3Lg2KibvVHEtdQqmCB9UebWF2WRwg$
> >>
>
> 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
>
> <ian.bertola...@workday.com.invalid> 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