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

Pushdown filters for Boolean type when query from HBase #305

Open
wants to merge 1 commit into
base: branch-2.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ object BoundRange extends Logging{
Some(BoundRanges(Array(BoundRange(min, b)),Array(BoundRange(b, max)), b))
}

case _: Array[Byte] | _: Byte | _: String | _: UTF8String =>
case _: Array[Byte] | _: Byte | _: String | _: UTF8String | _: Boolean =>
Some(BoundRanges(
Array(BoundRange(Array.fill(b.length)(ByteMin), b)),
Array(BoundRange(b, Array.fill(b.length)(ByteMax))), b))
Expand Down
14 changes: 11 additions & 3 deletions core/src/test/scala/org/apache/spark/sql/ScanRangeTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

package org.apache.spark.sql

import org.apache.spark.sql.execution.datasources.hbase.Logging
import org.apache.spark.sql.execution.datasources.hbase.{Bound, BoundRange, Field, Logging, ScanRange}
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, FunSuite}

import org.apache.hadoop.hbase.util.Bytes
import org.apache.spark.sql.execution.datasources.hbase
import org.apache.spark.sql.execution.datasources.hbase.{Bound, ScanRange}
import org.apache.spark.sql.execution.datasources.hbase.types.SHCDataTypeFactory
import org.apache.spark.sql.types.BinaryType

class ScanRangeTestSuite extends FunSuite with BeforeAndAfterEach with BeforeAndAfterAll with Logging {
Expand Down Expand Up @@ -487,4 +486,13 @@ class ScanRangeTestSuite extends FunSuite with BeforeAndAfterEach with BeforeAn

assert(v.size == ret.size && v.toSet == ret)
}

test("Test BoundRange") {
val f = Field("col1", "f", "col1", "PrimitiveType", Some("boolean"), None, -1)
val coder = SHCDataTypeFactory.create(f)
val bBoolean = BoundRange(true.asInstanceOf[Any], f)

display
assert(!bBoolean.isEmpty && coder.fromBytes(bBoolean.get.value).asInstanceOf[Boolean])
}
}