Hive算子下推使用Hive命令来执行。
本次任务示例使用tpch的1T数据的非分区表作为测试表,测试SQL为tpch-sql6。
相关的表信息如表1所示。
具体步骤如下。
1 2 |
cd /opt/hive vim tpch_ndp.setting |
1 2 3 4 5 6 7 8 9 10 |
set hive.execution.engine=tez; set hive.mapjoin.hybridgrace.hashtable=false; set hive.vectorized.execution.mapjoin.native.fast.hashtable.enabled=true; set omnidata.hive.enabled=true; set omnidata.hive.filter.selectivity.enabled=false; set omnidata.hive.filter.selectivity=0.5; set omnidata.hive.table.size.threshold=10240; set omnidata.hive.zookeeper.quorum.server=agent1:2181,agent2:2181,agent3:2181; set omnidata.hive.zookeeper.status.node=/sdi/status; set omnidata.hive.zookeeper.conf.path=/usr/local/zookeeper/conf; |
以上的参数也可以通过set命令直接在Hive中设置。
新增算子下推的参数信息如表2所示。
参数 |
缺省值 |
含义 |
---|---|---|
omnidata.hive.enabled |
true |
开启算子下推。 |
omnidata.hive.filter.selectivity.enabled |
true |
开启filter选择率来判断是否下推。 算子下推的收益和filter过滤的数据量相关,过滤的数据量越多,性能收益越明显,建议打开。 |
omnidata.hive.filter.selectivity |
0.5 |
filter选择率小于该值才会下推(selectivity越小,表示过滤后的剩余的数据量越小),缺省值为0.5,类型为double。取值范围为0.0~1.0。 |
omnidata.hive.table.size.threshold |
10240 |
查询的表大于该值才会执行下推,单位为字节,取值范围0~102400。 |
omnidata.hive.zookeeper.quorum.server |
localhost:2181 |
连接到ZooKeeper的地址。 客户场景中启动ZooKeeper的IP地址和端口号,可配置多台,以英文逗号分隔。 |
omnidata.hive.zookeeper.status.node |
/sdi/status |
OmniData算子下推注册到ZooKeeper的目录。 |
omnidata.hive.zookeeper.conf.path |
/usr/local/zookeeper/conf |
ZooKeeper配置文件地址。 |
1
|
/usr/local/hive/bin/hive -i /opt/hive/tpch_ndp.setting -database tpch_flat_orc_date_1000 |
select sum(l_extendedprice * l_discount) as revenue from tpch_flat_orc_1000.lineitem where l_shipdate >= '1993-01-01' and l_shipdate < '1994-01-01' and l_discount between 0.06 - 0.01 and 0.06 + 0.01 and l_quantity < 25;
执行任务时会打印下推的信息,如下所示。
Table [lineitem] Push Down Info [ Select:[DoubleColMultiplyDoubleColumn(col 5:double, col 6:double) -> 17:double], Filter:[GenericUDFOPAnd(GenericUDFOPEqualOrGreaterThan(Column[l_shipdate], Const date 1993-01-01), GenericUDFOPLessThan(Column[l_shipdate], Const date 1994-01-01), GenericUDFBetween(Const boolean false, Column[l_discount], Const double 0.05, Const double 0.07), GenericUDFOPLessThan(Column[l_quantity], Const double 25.0))], Aggregation:[sum(_col0)], Group By:[], Limit:[], Raw Filter:[], Host Map:[hdfs1 -> hdfs1, hdfs2 -> hdfs2, hdfs3 -> hdfs3]
包含了算子信息。