Skip to content

Commit

Permalink
undo
Browse files Browse the repository at this point in the history
  • Loading branch information
云峤 committed May 3, 2015
1 parent f080f8d commit 7b9b858
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
3 changes: 1 addition & 2 deletions sql/core/src/main/scala/org/apache/spark/sql/Column.scala
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ class Column(protected[sql] val expr: Expression) extends Logging {
* @group java_expr_ops
*/
def between(lowerBound: Column, upperBound: Column): Column = {
And(GreaterThanOrEqual(this.expr, lowerBound.expr),
LessThanOrEqual(this.expr, upperBound.expr))
(this >= lowerBound) && (this <= upperBound)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,17 @@ class ColumnExpressionSuite extends QueryTest {
}

test("between") {
checkAnswer(
testData4.filter($"a".between($"b", $"c")),
testData4.collect().toSeq.filter(r => r.getInt(0) >= r.getInt(1) && r.getInt(0) <= r.getInt(2)))
val testData = TestSQLContext.sparkContext.parallelize(
(0, 1, 2) ::
(1, 2, 3) ::
(2, 1, 0) ::
(2, 2, 4) ::
(3, 1, 6) ::
(3, 2, 0) :: Nil).toDF("a", "b", "c")
testData.registerTempTable("TestData4")
checkAnswer(
testData.filter($"a".between($"b", $"c")),
testData.collect().toSeq.filter(r => r.getInt(0) >= r.getInt(1) && r.getInt(0) <= r.getInt(2)))
}

val booleanData = TestSQLContext.createDataFrame(TestSQLContext.sparkContext.parallelize(
Expand Down
11 changes: 0 additions & 11 deletions sql/core/src/test/scala/org/apache/spark/sql/TestData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@ object TestData {
TestData2(3, 2) :: Nil, 2).toDF()
testData2.registerTempTable("testData2")

case class TestData4(a: Int, b: Int, c: Int)
val testData4 =
TestSQLContext.sparkContext.parallelize(
TestData4(0, 1, 2) ::
TestData4(1, 2, 3) ::
TestData4(2, 1, 0) ::
TestData4(2, 2, 4) ::
TestData4(3, 1, 6) ::
TestData4(3, 2, 0) :: Nil, 2).toDF()
testData4.registerTempTable("TestData4")

case class DecimalData(a: BigDecimal, b: BigDecimal)

val decimalData =
Expand Down

0 comments on commit 7b9b858

Please sign in to comment.