Skip to content
Closed
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 @@ -679,7 +679,7 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
def unapply(expr: Expression): Option[Attribute] = {
expr match {
case attr: Attribute => Some(attr)
case Cast(child @ AtomicType(), dt: AtomicType, _)
case Cast(child @ IntegralType(), dt: IntegralType, _)
if Cast.canSafeCast(child.dataType.asInstanceOf[AtomicType], dt) => unapply(child)
case _ => None
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.scalatest.BeforeAndAfterAll
import org.apache.spark.sql.catalyst.catalog._
import org.apache.spark.sql.catalyst.dsl.expressions._
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.types.{BooleanType, IntegerType, LongType}
import org.apache.spark.sql.types.{BooleanType, IntegerType, LongType, StringType}
import org.apache.spark.util.Utils

// TODO: Refactor this to `HivePartitionFilteringSuite`
Expand Down Expand Up @@ -258,6 +258,13 @@ class HiveClientSuite(version: String)
buildClient(new Configuration(), sharesHadoopClasses = false)
}

test("getPartitionsByFilter: chunk in ('ab', 'ba') and ((cast(ds as string)>'20170102')") {
val day = (20170101 to 20170103, 0 to 23, Seq("ab", "ba"))
testMetastorePartitionFiltering(
attr("chunk").in("ab", "ba") && (attr("ds").cast(StringType) > "20170102"),
day :: Nil)
}

private def testMetastorePartitionFiltering(
filterExpr: Expression,
expectedDs: Seq[Int],
Expand Down