Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public List<Rule> buildRules() {
return ImmutableList.of(
// Aggregate(Scan)
logicalAggregate(logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalAggregate<LogicalOlapScan> agg = ctx.root;
LogicalOlapScan scan = agg.child();
PreAggStatus preAggStatus = checkKeysType(scan);
Expand All @@ -96,7 +96,7 @@ public List<Rule> buildRules() {
// Aggregate(Filter(Scan))
logicalAggregate(
logicalFilter(logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet)))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalAggregate<LogicalFilter<LogicalOlapScan>> agg = ctx.root;
LogicalFilter<LogicalOlapScan> filter = agg.child();
LogicalOlapScan scan = filter.child();
Expand All @@ -117,7 +117,7 @@ public List<Rule> buildRules() {
// Aggregate(Project(Scan))
logicalAggregate(logicalProject(
logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet)))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalAggregate<LogicalProject<LogicalOlapScan>> agg =
ctx.root;
LogicalProject<LogicalOlapScan> project = agg.child();
Expand All @@ -141,7 +141,7 @@ public List<Rule> buildRules() {
// Aggregate(Project(Filter(Scan)))
logicalAggregate(logicalProject(logicalFilter(
logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet))))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalAggregate<LogicalProject<LogicalFilter<LogicalOlapScan>>> agg = ctx.root;
LogicalProject<LogicalFilter<LogicalOlapScan>> project = agg.child();
LogicalFilter<LogicalOlapScan> filter = project.child();
Expand All @@ -164,7 +164,7 @@ public List<Rule> buildRules() {
// Aggregate(Filter(Project(Scan)))
logicalAggregate(logicalFilter(logicalProject(
logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet))))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalAggregate<LogicalFilter<LogicalProject<LogicalOlapScan>>> agg = ctx.root;
LogicalFilter<LogicalProject<LogicalOlapScan>> filter =
agg.child();
Expand All @@ -189,7 +189,7 @@ public List<Rule> buildRules() {
// Aggregate(Repeat(Scan))
logicalAggregate(
logicalRepeat(logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet)))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalAggregate<LogicalRepeat<LogicalOlapScan>> agg = ctx.root;
LogicalRepeat<LogicalOlapScan> repeat = agg.child();
LogicalOlapScan scan = repeat.child();
Expand All @@ -209,7 +209,7 @@ public List<Rule> buildRules() {
// Aggregate(Repeat(Filter(Scan)))
logicalAggregate(logicalRepeat(logicalFilter(
logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet))))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalAggregate<LogicalRepeat<LogicalFilter<LogicalOlapScan>>> agg = ctx.root;
LogicalRepeat<LogicalFilter<LogicalOlapScan>> repeat = agg.child();
LogicalFilter<LogicalOlapScan> filter = repeat.child();
Expand All @@ -231,7 +231,7 @@ public List<Rule> buildRules() {
// Aggregate(Repeat(Project(Scan)))
logicalAggregate(logicalRepeat(logicalProject(
logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet))))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalAggregate<LogicalRepeat<LogicalProject<LogicalOlapScan>>> agg = ctx.root;
LogicalRepeat<LogicalProject<LogicalOlapScan>> repeat = agg.child();
LogicalProject<LogicalOlapScan> project = repeat.child();
Expand All @@ -254,7 +254,7 @@ public List<Rule> buildRules() {
// Aggregate(Repeat(Project(Filter(Scan))))
logicalAggregate(logicalRepeat(logicalProject(logicalFilter(
logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet)))))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalAggregate<LogicalRepeat<LogicalProject<LogicalFilter<LogicalOlapScan>>>> agg
= ctx.root;
LogicalRepeat<LogicalProject<LogicalFilter<LogicalOlapScan>>> repeat = agg.child();
Expand All @@ -280,7 +280,7 @@ public List<Rule> buildRules() {
// Aggregate(Repeat(Filter(Project(Scan))))
logicalAggregate(logicalRepeat(logicalFilter(logicalProject(
logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet)))))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalAggregate<LogicalRepeat<LogicalFilter<LogicalProject<LogicalOlapScan>>>> agg
= ctx.root;
LogicalRepeat<LogicalFilter<LogicalProject<LogicalOlapScan>>> repeat = agg.child();
Expand All @@ -307,7 +307,7 @@ public List<Rule> buildRules() {
// Filter(Project(Scan))
logicalFilter(logicalProject(
logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet)))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalFilter<LogicalProject<LogicalOlapScan>> filter = ctx.root;
LogicalProject<LogicalOlapScan> project = filter.child();
LogicalOlapScan scan = project.child();
Expand All @@ -326,7 +326,7 @@ public List<Rule> buildRules() {

// Filter(Scan)
logicalFilter(logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet))
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalFilter<LogicalOlapScan> filter = ctx.root;
LogicalOlapScan scan = filter.child();
PreAggStatus preAggStatus = checkKeysType(scan);
Expand All @@ -342,7 +342,7 @@ public List<Rule> buildRules() {

// only scan.
logicalOlapScan().when(LogicalOlapScan::isPreAggStatusUnSet)
.thenApplyNoThrow(ctx -> {
.thenApply(ctx -> {
LogicalOlapScan scan = ctx.root;
PreAggStatus preAggStatus = checkKeysType(scan);
if (preAggStatus == PreAggStatus.unset()) {
Expand Down Expand Up @@ -500,7 +500,10 @@ private PreAggStatus checkAggregateFunctions(List<AggregateFunction> aggregateFu
? PreAggStatus.off("No aggregate on scan.")
: PreAggStatus.on();
for (AggregateFunction aggFunc : aggregateFuncs) {
if (aggFunc.children().size() == 1 && aggFunc.child(0) instanceof Slot) {
if (aggFunc.children().isEmpty()) {
preAggStatus = PreAggStatus.off(
String.format("can't turn preAgg on for aggregate function %s", aggFunc));
} else if (aggFunc.children().size() == 1 && aggFunc.child(0) instanceof Slot) {
Slot aggSlot = (Slot) aggFunc.child(0);
if (aggSlot instanceof SlotReference
&& ((SlotReference) aggSlot).getColumn().isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ public boolean hasDeleteSign() {
PlanChecker.from(connectContext)
.parse("select * from " + tableName + " as et join db1.t on et.id = t.a")
.customAnalyzer(Optional.of(customTableResolver)) // analyze internal relation
.rewrite()
.matches(
logicalJoin(
logicalOlapScan().when(r -> r.getTable() == externalOlapTable),
logicalOlapScan().when(r -> r.getTable().getName().equals("t"))
logicalSubQueryAlias(
logicalOlapScan().when(r -> r.getTable() == externalOlapTable)
),
logicalOlapScan().when(r -> r.getTable().getName().equals("t"))
)
);
}
Expand Down