caicancai commented on code in PR #4013:
URL: https://github.com/apache/calcite/pull/4013#discussion_r1812914225
##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java:
##########
@@ -184,19 +180,12 @@ private static Set<ImmutableBitSet>
getProjectUniqueKeys(SingleRel rel, RelMetad
continue;
}
// colMask is mapped to output project, however, the column can be
mapped more than once:
- // select id, id, id, unique2, unique2
- // the resulting unique keys would be {{0},{3}}, {{0},{4}},
{{0},{1},{4}}, ...
-
- Iterable<List<ImmutableBitSet>> product =
- Linq4j.product(
- Util.transform(colMask, in ->
- Util.filter(
- requireNonNull(mapInToOutPos.get(in),
- () -> "no entry for column " + in
- + " in mapInToOutPos: " +
mapInToOutPos).powerSet(),
- bs -> !bs.isEmpty())));
-
- resultBuilder.addAll(Util.transform(product, ImmutableBitSet::union));
+ // select key1, key1, val1, val2, key2 from ...
+ // the resulting unique keys would be {{0},{4}}, {{1},{4}}
Review Comment:
for example,
```
// Select fields key1, key1, val1, val2, and key2
// The query results will return records with unique key combinations
// Example of unique key combinations:
// {{0}, {4}} indicates that the key1 value of the first record is 0, and
the key2 value is 4
// {{1}, {4}} indicates that the key1 value of the second record is 1, and
the key2 value is 4
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]