presto - 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.
解决方案
下载源代码并在调试器中运行后,我发现它一方面相当简单,另一方面又受到限制。
直截了当的部分是我们只需要在实现接口时重写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();
}
推荐阅读
- python - python - 如何将csv行的第一项作为python中的列表名称?
- ruby - Ruby:nokogiri 需要 Ruby 版本 < 3.1.dev, >= 2.5
- python - python pd.read_excel [WinError 32] 该进程无法访问该文件,因为它正在被另一个进程使用
- javascript - 在返回节点之前等待嵌套循环完成
- php - 使用 PHPWord 更改布局、边框将 docx 转换为 PDF,
- python - Qt 动态属性 - 如果不是父级,则适用于小部件?
- postgresql - Postgres 订阅未启用
- html - 是否有必要将用户提交的数据转义到 HTML 输入值中?
- jackson - 如何忽略@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
- export-to-csv - Snowflake COPY INTO Export 产生不可读的文件