[fix](plan) fix wrong result for random distributed agg table with all keys not null (#36271)
This commit is contained in:
@ -868,6 +868,10 @@ public class OlapTable extends Table implements MTMVRelatedTableIf {
|
||||
return distributionColumnNames;
|
||||
}
|
||||
|
||||
public boolean isRandomDistribution() {
|
||||
return defaultDistributionInfo instanceof RandomDistributionInfo;
|
||||
}
|
||||
|
||||
public void renamePartition(String partitionName, String newPartitionName) {
|
||||
if (partitionInfo.getType() == PartitionType.UNPARTITIONED) {
|
||||
// bug fix
|
||||
|
||||
@ -137,18 +137,21 @@ public abstract class LogicalCatalogRelation extends LogicalRelation implements
|
||||
@Override
|
||||
public void computeUnique(FunctionalDependencies.Builder fdBuilder) {
|
||||
Set<Slot> outputSet = Utils.fastToImmutableSet(getOutputSet());
|
||||
if (table instanceof OlapTable && ((OlapTable) table).getKeysType().isAggregationFamily()) {
|
||||
ImmutableSet.Builder<Slot> uniqSlots = ImmutableSet.builderWithExpectedSize(outputSet.size());
|
||||
for (Slot slot : outputSet) {
|
||||
if (!(slot instanceof SlotReference)) {
|
||||
continue;
|
||||
}
|
||||
SlotReference slotRef = (SlotReference) slot;
|
||||
if (slotRef.getColumn().isPresent() && slotRef.getColumn().get().isKey()) {
|
||||
uniqSlots.add(slot);
|
||||
if (table instanceof OlapTable) {
|
||||
OlapTable olapTable = (OlapTable) table;
|
||||
if (olapTable.getKeysType().isAggregationFamily() && !olapTable.isRandomDistribution()) {
|
||||
ImmutableSet.Builder<Slot> uniqSlots = ImmutableSet.builderWithExpectedSize(outputSet.size());
|
||||
for (Slot slot : outputSet) {
|
||||
if (!(slot instanceof SlotReference)) {
|
||||
continue;
|
||||
}
|
||||
SlotReference slotRef = (SlotReference) slot;
|
||||
if (slotRef.getColumn().isPresent() && slotRef.getColumn().get().isKey()) {
|
||||
uniqSlots.add(slot);
|
||||
}
|
||||
}
|
||||
fdBuilder.addUniqueSlot(uniqSlots.build());
|
||||
}
|
||||
fdBuilder.addUniqueSlot(uniqSlots.build());
|
||||
}
|
||||
|
||||
for (PrimaryKeyConstraint c : table.getPrimaryKeyConstraints()) {
|
||||
|
||||
Reference in New Issue
Block a user