我想扩展Presto的example-http
连接器,以将相关谓词添加到连接器进行的REST API调用中,以最大程度地减少数据传输。
我现在已经花了几个小时来浏览文档,在线帖子和presto源代码,但是我无法弄清楚涉及哪些调用以及如何处理。
它在很多地方都被提及,但是我找不到任何简单的代码示例或内部描述。我确定我这里缺少明显的东西。
下载源代码并在调试器中运行后,我发现一方面是相当简单的,另一方面是限制性的。
直接的部分是,在实现isPushdownFilterSupported
接口时,我们只需要重写pushdownFilter
和ConnectorMetadata
。
限制性部分是查询计划者现在认为连接器可以处理任何类型和组合的表过滤器。就我而言,我只想照顾那些,我正在调用的远程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();
}