【问题标题】:How to use pushdown predicates in Presto connector如何在 Presto 连接器中使用下推谓词
【发布时间】:2020-02-19 08:14:58
【问题描述】:

我想扩展 Presto 的 example-http 连接器,将相关谓词添加到连接器进行的 REST API 调用中,以最大程度地减少数据传输。

我现在已经花费了好几个小时来查看文档、在线帖子和 presto 源代码,但我无法弄清楚涉及哪些调用以及如何进行此操作。

很多地方都提到了它,但我找不到任何简单的代码示例或内部描述。我确定我在这里遗漏了一些明显的东西。

【问题讨论】:

  • 您是否尝试在Presto community slack#dev 频道上直接获得帮助?
  • 不,我没有,但感谢您的建议。我相信我会在未来使用它。

标签: presto connector


【解决方案1】:

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

直截了当的部分是我们只需要在实现ConnectorMetadata 接口时覆盖isPushdownFilterSupportedpushdownFilter

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

Presto 团队似乎完全意识到这一点,因为 a) 方法标记为 @Experimental 和 b) 由各自的 cmets 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();
    }

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-06
  • 2019-07-19
  • 1970-01-01
  • 2019-07-04
  • 2019-01-21
  • 1970-01-01
  • 2018-01-07
相关资源
最近更新 更多