为什么谓词下推不起作用? [英] Why is predicate pushdown not working?

查看:219
本文介绍了为什么谓词下推不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我创建了一个HiveContext hiveContext.
  • 在这种情况下,我从JDBC关系表中创建了一个DataFrame df.
  • 我通过df.registerTempTable("TESTTABLE")注册了DataFrame df.
  • 我通过启动HiveThriftServer2 HiveThriftServer2.startWithContext(hiveContext).
  • I create a HiveContext hiveContext.
  • With that context, I create a DataFrame df from a JDBC relational table.
  • I register the DataFrame df via df.registerTempTable("TESTTABLE").
  • I start a HiveThriftServer2 via HiveThriftServer2.startWithContext(hiveContext).

TESTTABLE包含1,000,000个条目,列为ID(INT)和NAME(VARCHAR)

The TESTTABLE contains 1,000,000 entries, columns are ID (INT) and NAME (VARCHAR)

+-----+--------+
| ID  |  NAME  |
+-----+--------+
| 1   | Hello  |
| 2   | Hello  |
| 3   | Hello  |
| ... | ...    |

使用Beeline,我访问HiveThriftServer的SQL端点(端口10000)并执行查询.例如

With Beeline I access the SQL Endpoint (at port 10000) of the HiveThriftServer and perform a query. E.g.

SELECT * FROM TESTTABLE WHERE ID='3'

当我检查执行了SQL语句的数据库的QueryLog时,看到了

When I inspect the QueryLog of the DB with the SQL Statements executed I see

/*SQL #:1000000 t:657*/  SELECT \"ID\",\"NAME\" FROM test;

因此,因为没有where子句,所以没有谓词下推.

So there happens no predicate pushdown , as the where clause is missing.

这引起了以下问题:

  • 为什么不执行谓词下推?
  • 可以通过不使用registerTempTable来更改此设置吗?
  • 如果是这样,怎么办?还是这是HiveThriftServer的已知限制?

如果我在Spark SQLContext中创建一个DataFrame df并调用

If I create a DataFrame df in Spark SQLContext and call

df.filter( df("ID") === 3).show()

我观察

/*SQL #:1*/SELECT \"ID\",\"NAME\" FROM test WHERE ID = 3;

符合预期.

推荐答案

回答可能为时已晚. 在这种情况下,这是行不通的,因为ID被定义为Int,并且在原始查询中您正在传递字符串('3').谓词下推也会查找相同的列名和类型.

It's probably too late to answer. In this scenario, this did not work because ID is defined as Int and in the original query you are passing a string ('3'). Predicate pushdown looks for the same column name and the type as well.

这篇关于为什么谓词下推不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆