Skip to content

Commit d477ea1

Browse files
committed
Add SPI to customize expression optimization
1 parent fd10129 commit d477ea1

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

presto-spi/src/main/java/com/facebook/presto/spi/CoordinatorPlugin.java

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.facebook.presto.spi.function.FunctionNamespaceManagerFactory;
1717
import com.facebook.presto.spi.plan.PlanCheckerProviderFactory;
1818
import com.facebook.presto.spi.session.WorkerSessionPropertyProviderFactory;
19+
import com.facebook.presto.spi.sql.planner.ExpressionOptimizerFactory;
1920

2021
import static java.util.Collections.emptyList;
2122

@@ -40,4 +41,9 @@ default Iterable<PlanCheckerProviderFactory> getPlanCheckerProviderFactories()
4041
{
4142
return emptyList();
4243
}
44+
45+
default Iterable<ExpressionOptimizerFactory> getExpressionOptimizerFactories()
46+
{
47+
return emptyList();
48+
}
4349
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.facebook.presto.spi.sql.planner;
15+
16+
import com.facebook.presto.spi.NodeManager;
17+
import com.facebook.presto.spi.function.FunctionMetadataManager;
18+
import com.facebook.presto.spi.function.StandardFunctionResolution;
19+
20+
import static java.util.Objects.requireNonNull;
21+
22+
public class ExpressionOptimizerContext
23+
{
24+
private final NodeManager nodeManager;
25+
private final FunctionMetadataManager functionMetadataManager;
26+
private final StandardFunctionResolution functionResolution;
27+
28+
public ExpressionOptimizerContext(NodeManager nodeManager, FunctionMetadataManager functionMetadataManager, StandardFunctionResolution functionResolution)
29+
{
30+
this.nodeManager = requireNonNull(nodeManager, "nodeManager is null");
31+
this.functionMetadataManager = requireNonNull(functionMetadataManager, "functionMetadataManager is null");
32+
this.functionResolution = requireNonNull(functionResolution, "functionResolution is null");
33+
}
34+
35+
public NodeManager getNodeManager()
36+
{
37+
return nodeManager;
38+
}
39+
40+
public FunctionMetadataManager getFunctionMetadataManager()
41+
{
42+
return functionMetadataManager;
43+
}
44+
45+
public StandardFunctionResolution getFunctionResolution()
46+
{
47+
return functionResolution;
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.facebook.presto.spi.sql.planner;
15+
16+
import com.facebook.presto.spi.relation.ExpressionOptimizer;
17+
18+
import java.util.Map;
19+
20+
public interface ExpressionOptimizerFactory
21+
{
22+
ExpressionOptimizer createOptimizer(Map<String, String> config, ExpressionOptimizerContext context);
23+
24+
String getName();
25+
}

0 commit comments

Comments
 (0)