Skip to content

Commit

Permalink
fixes the style comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
gatorsmile committed Nov 25, 2015
1 parent 0d62b5e commit 458cf67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,15 @@ class Dataset[T] private[sql](
c5: TypedColumn[T, U5]): Dataset[(U1, U2, U3, U4, U5)] =
selectUntyped(c1, c2, c3, c4, c5).asInstanceOf[Dataset[(U1, U2, U3, U4, U5)]]


/**
* Returns a new [[Dataset]] by sampling a fraction of rows.
* Returns a new [[Dataset]] by sampling a fraction of records.
* @since 1.6.0
*/
def sample(withReplacement: Boolean, fraction: Double, seed: Long) : Dataset[T] =
withPlan(Sample(0.0, fraction, withReplacement, seed, _))

/**
* Returns a new [[Dataset]] by sampling a fraction of rows, using a random seed.
* Returns a new [[Dataset]] by sampling a fraction of records, using a random seed.
* @since 1.6.0
*/
def sample(withReplacement: Boolean, fraction: Double) : Dataset[T] = {
Expand Down Expand Up @@ -560,7 +559,7 @@ class Dataset[T] private[sql](

/**
* Using inner equi-join to join this [[Dataset]] returning a [[Tuple2]] for each pair
* where `condition` evaluates to true
* where `condition` evaluates to true.
*
* @param other Right side of the join.
* @param condition Join expression.
Expand Down
12 changes: 6 additions & 6 deletions sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
test("joinWith, expression condition, outer join") {
val nullInteger = null.asInstanceOf[Integer]
val nullString = null.asInstanceOf[String]
val ds1 = Seq(ClassNullableData("a", new Integer(1)),
ClassNullableData("c", new Integer(3))).toDS()
val ds1 = Seq(ClassNullableData("a", 1),
ClassNullableData("c", 3)).toDS()
val ds2 = Seq(("a", new Integer(1)),
("b", new Integer(2))).toDS()

checkAnswer(
ds1.joinWith(ds2, $"_1" === $"a", "outer"),
(ClassNullableData("a", new Integer(1)), ("a", new Integer(1))),
(ClassNullableData("c", new Integer(3)), (nullString, nullInteger)),
(ClassNullableData("a", 1), ("a", new Integer(1))),
(ClassNullableData("c", 3), (nullString, nullInteger)),
(ClassNullableData(nullString, nullInteger), ("b", new Integer(2))))
}

Expand Down Expand Up @@ -377,15 +377,15 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
val data = sparkContext.parallelize(1 to n, 2).toDS()
checkAnswer(
data.sample(withReplacement = true, 0.05, seed = 13),
Seq(5, 10, 52, 73): _*)
5, 10, 52, 73)
}

test("sample without replacement") {
val n = 100
val data = sparkContext.parallelize(1 to n, 2).toDS()
checkAnswer(
data.sample(withReplacement = false, 0.05, seed = 13),
Seq(3, 17, 27, 58, 62): _*)
3, 17, 27, 58, 62)
}

test("SPARK-11436: we should rebind right encoder when join 2 datasets") {
Expand Down

0 comments on commit 458cf67

Please sign in to comment.