Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-27488 [hbase-connectors] Duplicate result when searching HBase by Spark #106

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,20 @@ class HBaseTableScanRDD(relation: HBaseRelation,
hbaseContext: HBaseContext): Iterator[Result] = {
g.grouped(relation.bulkGetSize).flatMap{ x =>
val gets = new ArrayList[Get](x.size)
val rowkeySet = new mutable.HashSet[String]()
x.foreach{ y =>
val g = new Get(y)
handleTimeSemantics(g)
columns.foreach { d =>
if (!d.isRowKey) {
g.addColumn(d.cfBytes, d.colBytes)
if (!rowkeySet.contains(y.mkString("Array(", ", ", ")"))) {
val g = new Get(y)
handleTimeSemantics(g)
columns.foreach { d =>
if (!d.isRowKey) {
g.addColumn(d.cfBytes, d.colBytes)
}
}
filter.foreach(g.setFilter(_))
gets.add(g)
rowkeySet.add(y.mkString("Array(", ", ", ")"))
}
filter.foreach(g.setFilter(_))
gets.add(g)
}
hbaseContext.applyCreds()
val tmp = tbr.get(gets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,22 @@ BeforeAndAfterEach with BeforeAndAfterAll with Logging {
assert(executionRules.rowKeyFilter.ranges.size == 0)
}

/**
* A example of query three fields and also only using rowkey points for the filter,
* some rowkey points are duplicate.
*/
test("Test rowKey point only rowKey query, which contains duplicate rowkey") {
val results = sqlContext.sql("SELECT KEY_FIELD, B_FIELD, A_FIELD FROM hbaseTable1 " +
"WHERE " +
"(KEY_FIELD = 'get1' or KEY_FIELD = 'get2' or KEY_FIELD = 'get1')").take(10)
val executionRules = DefaultSourceStaticUtils.lastFiveExecutionRules.poll()
assert(results.length == 2)
assert(executionRules.dynamicLogicExpression.toExpressionString.
equals("( ( KEY_FIELD == 0 OR KEY_FIELD == 1 ) OR KEY_FIELD == 2 )"))
assert(executionRules.rowKeyFilter.points.size == 3)
assert(executionRules.rowKeyFilter.ranges.size == 0)
}

/**
* A example of query three fields and also only using cell points for the filter
*/
Expand Down