首页 > 解决方案 > How to use pushdown predicates in Presto connector

问题描述

I would like to extend Presto's example-http connector to add the relevant predicates to the REST API call made by the connector to minimize data transfer.

I have been spending now quite a few hours looking through the documentation, online posts and the presto source code but I can't figure out which calls are involved and how to go about this.

It's being mentioned in so many places, but I cannot find any simple code samples or internal descriptions. I'm sure I'm missing something obvious here.

标签: prestoconnector

解决方案


下载源代码并在调试器中运行后,我发现它一方面相当简单,另一方面又受到限制。

直截了当的部分是我们只需要在实现接口时重写isPushdownFilterSupported和。pushdownFilterConnectorMetadata

限制性部分是查询计划器现在认为连接器可以处理任何类型和组合的表过滤器。在我的情况下,我只想处理那些,我正在调用的远程 API 支持并让 Presto 处理其余的。

Presto 团队似乎完全意识到这一点,因为 a) 方法被标记@Experimental并且 b) 由各自的评论This interface can be replaced with a connector optimizer rule once the engine supports these (#12546).这显然是我的用例的正确方法。

   /**
     * Experimental: if true, the engine will invoke pushdownFilter instead of getTableLayouts.
     *
     * This interface can be replaced with a connector optimizer rule once the engine supports these (#12546).
     */
    @Experimental
    default boolean isPushdownFilterSupported(ConnectorSession session, ConnectorTableHandle tableHandle)
    {
        return false;
    }

    /**
     * Experimental: returns table layout that encapsulates the given filter.
     *
     * This interface can be replaced with a connector optimizer rule once the engine supports these (#12546).
     */
    @Experimental
    default ConnectorPushdownFilterResult pushdownFilter(ConnectorSession session, ConnectorTableHandle tableHandle, RowExpression filter, Optional<ConnectorTableLayoutHandle> currentLayoutHandle)
    {
        throw new UnsupportedOperationException();
    }

推荐阅读