对于火花凤凰,我不想从HBase中提取全部数据。有什么方法可以根据我的条件从表中提取数据吗?



从Hbase中提取全部数据太慢。我只需要处理一个小时的数据。

所以我想知道我是否可以在配置中指定SQL并像Spark支持JDBC连接一样拉一个小时的数据?或者它支持下推,我只需要写SparkSQL?

我用的是phoenix-4.14.1-HBase-1.3

OK。我找到了答案。凤凰不支持下推。我的错误是我一开始用的是substr,应该用startsWith或者like代替。

证据如下。

/*
This is the buildScan() implementing Spark's PrunedFilteredScan.
Spark SQL queries with columns or predicates specified will be pushed down
to us here, and we can pass that on to Phoenix. According to the docs, this
is an optimization, and the filtering/pruning will be re-evaluated again,
but this prevents having to load the whole table into Spark first.
*/
override def buildScan(requiredColumns: Array[String], filters: Array[Filter]): RDD[Row] = {
new PhoenixRDD(
sqlContext.sparkContext,
tableName,
requiredColumns,
Some(buildFilter(filters)),
Some(zkUrl),
new Configuration(),
dateAsTimestamp
).toDataFrame(sqlContext).rdd
}