Patent ID: 7577647

Claim:
A method for transforming a query tree that includes more than one aggregator, the method implemented on a processor coupled to a memory, the method comprising: a. identifying a first aggregator in the query tree; b. identifying a second aggregator that is located below the first aggregator in the query tree; c. identifying an apply operator between the first and second aggregators in the query tree; d. merging the second aggregator with the first aggregator to form a merged aggregator; e. determining whether the first aggregator is a merged aggregator before the merging of the first and second aggregators; f. if the first aggregator is a merged aggregator before the merging of the first and second aggregators, changing a join type of the apply operator from inner to full-outer with a false predicate; g. if the first aggregator is not a merged aggregator before the merging of the first and second aggregators, determining whether the second aggregator is a right-hand child to the apply operator before the merging of the first and second aggregators; h. if the second aggregator is a right-hand child to the apply operator before the merging of the first and second aggregators, changing a join type of the apply operator from inner to left-outer; and i. if the second aggregator is not a right-hand child to the apply operator before the merging of the first and second aggregators, changing a join type of the apply operator from inner to right-outer.