Skip to content

Commit

Permalink
Add SPI to customize expression optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
tdcmeehan committed Dec 11, 2024
1 parent d4e878b commit a446157
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
import com.facebook.presto.spi.function.FunctionNamespaceManagerFactory;
import com.facebook.presto.spi.plan.PlanCheckerProviderFactory;
import com.facebook.presto.spi.session.WorkerSessionPropertyProviderFactory;
import com.facebook.presto.spi.sql.planner.ExpressionOptimizerFactory;

import static java.util.Collections.emptyList;

/**
* The {@link CoordinatorPlugin} interface allows for plugins to provide additional functionality
* specifically for a coordinator in a Presto cluster. This is a successor to {@link Plugin} for
* coordinator specific plugins and will eventually replace it.
* Introduces a new {@link CoordinatorPlugin} interface for native C++ clusters.
* Certain elements of the {@link Plugin} SPI are not used in Prestissimo deployments, or may result in inconsistencies.
* The {@link CoordinatorPlugin} includes only the interfaces relevant to native C++ clusters and
* is a successor to {@link Plugin} and will eventually replace it.
* It contains only interfaces that are valid and used in a coordinator.
*/
public interface CoordinatorPlugin
{
Expand All @@ -40,4 +43,9 @@ default Iterable<PlanCheckerProviderFactory> getPlanCheckerProviderFactories()
{
return emptyList();
}

default Iterable<ExpressionOptimizerFactory> getExpressionOptimizerFactories()
{
return emptyList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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.spi.sql.planner;

import com.facebook.presto.spi.NodeManager;
import com.facebook.presto.spi.function.FunctionMetadataManager;
import com.facebook.presto.spi.function.StandardFunctionResolution;

import static java.util.Objects.requireNonNull;

public class ExpressionOptimizerContext
{
private final NodeManager nodeManager;
private final FunctionMetadataManager functionMetadataManager;
private final StandardFunctionResolution functionResolution;

public ExpressionOptimizerContext(NodeManager nodeManager, FunctionMetadataManager functionMetadataManager, StandardFunctionResolution functionResolution)
{
this.nodeManager = requireNonNull(nodeManager, "nodeManager is null");
this.functionMetadataManager = requireNonNull(functionMetadataManager, "functionMetadataManager is null");
this.functionResolution = requireNonNull(functionResolution, "functionResolution is null");
}

public NodeManager getNodeManager()
{
return nodeManager;
}

public FunctionMetadataManager getFunctionMetadataManager()
{
return functionMetadataManager;
}

public StandardFunctionResolution getFunctionResolution()
{
return functionResolution;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.spi.sql.planner;

import com.facebook.presto.spi.relation.ExpressionOptimizer;

import java.util.Map;

public interface ExpressionOptimizerFactory
{
ExpressionOptimizer createOptimizer(Map<String, String> config, ExpressionOptimizerContext context);

String getName();
}

0 comments on commit a446157

Please sign in to comment.