-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support CTE nodes in cost calculator
Summary: Supporting CTE logical nodes in cost calculator is crucial for calculating cost, this PR adds that.
- Loading branch information
1 parent
6d749f9
commit 946d4cd
Showing
17 changed files
with
639 additions
and
260 deletions.
There are no files selected for viewing
513 changes: 265 additions & 248 deletions
513
presto-hive/src/test/java/com/facebook/presto/hive/TestCteExecution.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
presto-main/src/main/java/com/facebook/presto/cost/CteConsumerStatsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.facebook.presto.cost; | ||
|
||
import com.facebook.presto.Session; | ||
import com.facebook.presto.matching.Pattern; | ||
import com.facebook.presto.spi.plan.CteConsumerNode; | ||
import com.facebook.presto.sql.planner.TypeProvider; | ||
import com.facebook.presto.sql.planner.iterative.Lookup; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.facebook.presto.sql.planner.plan.Patterns.cteConsumer; | ||
|
||
public class CteConsumerStatsRule | ||
implements ComposableStatsCalculator.Rule<CteConsumerNode> | ||
{ | ||
private static final Pattern<CteConsumerNode> PATTERN = cteConsumer(); | ||
|
||
@Override | ||
public Pattern<CteConsumerNode> getPattern() | ||
{ | ||
return PATTERN; | ||
} | ||
|
||
@Override | ||
public Optional<PlanNodeStatsEstimate> calculate(CteConsumerNode node, StatsProvider sourceStats, Lookup lookup, Session session, TypeProvider types) | ||
{ | ||
return Optional.of(sourceStats.getStats(node.getOriginalSource())); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
presto-main/src/main/java/com/facebook/presto/cost/CteProducerStatsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.facebook.presto.cost; | ||
|
||
import com.facebook.presto.Session; | ||
import com.facebook.presto.matching.Pattern; | ||
import com.facebook.presto.spi.plan.CteProducerNode; | ||
import com.facebook.presto.sql.planner.TypeProvider; | ||
import com.facebook.presto.sql.planner.iterative.Lookup; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.facebook.presto.sql.planner.plan.Patterns.cteProducer; | ||
|
||
public class CteProducerStatsRule | ||
implements ComposableStatsCalculator.Rule<CteProducerNode> | ||
{ | ||
private static final Pattern<CteProducerNode> PATTERN = cteProducer(); | ||
|
||
@Override | ||
public Pattern<CteProducerNode> getPattern() | ||
{ | ||
return PATTERN; | ||
} | ||
|
||
@Override | ||
public Optional<PlanNodeStatsEstimate> calculate(CteProducerNode node, StatsProvider sourceStats, Lookup lookup, Session session, TypeProvider types) | ||
{ | ||
return Optional.of(sourceStats.getStats(node.getSource())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
presto-main/src/main/java/com/facebook/presto/cost/SequenceStatsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.facebook.presto.cost; | ||
|
||
import com.facebook.presto.Session; | ||
import com.facebook.presto.matching.Pattern; | ||
import com.facebook.presto.spi.plan.SequenceNode; | ||
import com.facebook.presto.sql.planner.TypeProvider; | ||
import com.facebook.presto.sql.planner.iterative.Lookup; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.facebook.presto.sql.planner.plan.Patterns.sequenceNode; | ||
|
||
public class SequenceStatsRule | ||
implements ComposableStatsCalculator.Rule<SequenceNode> | ||
{ | ||
private static final Pattern<SequenceNode> PATTERN = sequenceNode(); | ||
|
||
@Override | ||
public Pattern<SequenceNode> getPattern() | ||
{ | ||
return PATTERN; | ||
} | ||
|
||
@Override | ||
public Optional<PlanNodeStatsEstimate> calculate(SequenceNode node, StatsProvider sourceStats, Lookup lookup, Session session, TypeProvider types) | ||
{ | ||
return Optional.of(sourceStats.getStats(node.getPrimarySource())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.