Skip to content

Commit

Permalink
add todo
Browse files Browse the repository at this point in the history
  • Loading branch information
feiniaofeiafei committed Nov 26, 2024
1 parent 08d1b5c commit f83a23b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@
public class DataTrait {

public static final DataTrait EMPTY_TRAIT
= new DataTrait(new NestedSet().toImmutable(),
= new DataTrait(new UniqueDescription().toImmutable(),
new UniformDescription().toImmutable(), new ImmutableSet.Builder<FdItem>().build(),
ImmutableEqualSet.empty(), new FuncDepsDG.Builder().build());
private final NestedSet uniqueSet;
private final UniqueDescription uniqueSet;
private final UniformDescription uniformSet;
private final ImmutableSet<FdItem> fdItems;
private final ImmutableEqualSet<Slot> equalSet;
private final FuncDepsDG fdDg;

private DataTrait(NestedSet uniqueSet, UniformDescription uniformSet, ImmutableSet<FdItem> fdItems,
private DataTrait(UniqueDescription uniqueSet, UniformDescription uniformSet, ImmutableSet<FdItem> fdItems,
ImmutableEqualSet<Slot> equalSet, FuncDepsDG fdDg) {
this.uniqueSet = uniqueSet;
this.uniformSet = uniformSet;
Expand Down Expand Up @@ -160,14 +160,14 @@ public String toString() {
* Builder of trait
*/
public static class Builder {
private final NestedSet uniqueSet;
private final UniqueDescription uniqueSet;
private final UniformDescription uniformSet;
private ImmutableSet<FdItem> fdItems;
private final ImmutableEqualSet.Builder<Slot> equalSetBuilder;
private final FuncDepsDG.Builder fdDgBuilder;

public Builder() {
uniqueSet = new NestedSet();
uniqueSet = new UniqueDescription();
uniformSet = new UniformDescription();
fdItems = new ImmutableSet.Builder<FdItem>().build();
equalSetBuilder = new ImmutableEqualSet.Builder<>();
Expand All @@ -176,7 +176,7 @@ public Builder() {

public Builder(DataTrait other) {
this.uniformSet = new UniformDescription(other.uniformSet);
this.uniqueSet = new NestedSet(other.uniqueSet);
this.uniqueSet = new UniqueDescription(other.uniqueSet);
this.fdItems = ImmutableSet.copyOf(other.fdItems);
equalSetBuilder = new ImmutableEqualSet.Builder<>(other.equalSet);
fdDgBuilder = new FuncDepsDG.Builder(other.fdDg);
Expand Down Expand Up @@ -374,21 +374,21 @@ public void replaceFuncDepsBy(Map<Slot, Slot> replaceMap) {
}
}

static class NestedSet {
static class UniqueDescription {
Set<Slot> slots;
Set<ImmutableSet<Slot>> slotSets;

NestedSet() {
UniqueDescription() {
slots = new HashSet<>();
slotSets = new HashSet<>();
}

NestedSet(NestedSet o) {
UniqueDescription(UniqueDescription o) {
this.slots = new HashSet<>(o.slots);
this.slotSets = new HashSet<>(o.slotSets);
}

NestedSet(Set<Slot> slots, Set<ImmutableSet<Slot>> slotSets) {
UniqueDescription(Set<Slot> slots, Set<ImmutableSet<Slot>> slotSets) {
this.slots = slots;
this.slotSets = slotSets;
}
Expand Down Expand Up @@ -444,9 +444,9 @@ public void add(ImmutableSet<Slot> slotSet) {
slotSets.add(slotSet);
}

public void add(NestedSet nestedSet) {
slots.addAll(nestedSet.slots);
slotSets.addAll(nestedSet.slotSets);
public void add(UniqueDescription uniqueDescription) {
slots.addAll(uniqueDescription.slots);
slotSets.addAll(uniqueDescription.slotSets);
}

public boolean isIntersect(Set<Slot> set1, Set<Slot> set2) {
Expand Down Expand Up @@ -482,8 +482,8 @@ public void replace(Map<Slot, Slot> replaceMap) {
.collect(Collectors.toSet());
}

public NestedSet toImmutable() {
return new NestedSet(ImmutableSet.copyOf(slots), ImmutableSet.copyOf(slotSets));
public UniqueDescription toImmutable() {
return new UniqueDescription(ImmutableSet.copyOf(slots), ImmutableSet.copyOf(slotSets));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ public void computeUniform(Builder builder) {
// outer join cant have nullable side uniform properties
// (e.g. left join may produce null in right side, the uniform value is present and not null
// cannot deduce the slot is uniform and not null)
// TODO: left outer join right child uniform properties can be pull up when uniform slot const value
// is not present or const value is nullable (the right outer join left child is same)
if (!joinType.isLeftJoin()) {
builder.addUniformSlot(right().getLogicalProperties().getTrait());
}
Expand Down
2 changes: 1 addition & 1 deletion regression-test/suites/mv_p0/count_star/count_star.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ suite ("count_star") {

sql "analyze table d_table with sync;"
sql """set enable_stats=false;"""

qt_select_star "select * from d_table order by k1,k2,k3,k4;"

mv_rewrite_success("select k1,k4,count(*) from d_table group by k1,k4;", "kstar")
Expand Down

0 comments on commit f83a23b

Please sign in to comment.