Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maropu committed Apr 29, 2020
1 parent 663fdc7 commit 4b1f3f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ trait ExpressionWithRandomSeed {
""",
since = "1.5.0")
// scalastyle:on line.size.limit
case class Rand(child: Expression, useRandSeed: Boolean = false)
case class Rand(child: Expression, hideSeed: Boolean = false)
extends RDG with ExpressionWithRandomSeed {

def this() = this(Literal(Utils.random.nextLong(), LongType), true)
Expand All @@ -104,11 +104,11 @@ case class Rand(child: Expression, useRandSeed: Boolean = false)
isNull = FalseLiteral)
}

override def freshCopy(): Rand = Rand(child)
override def freshCopy(): Rand = Rand(child, hideSeed)

override def flatArguments: Iterator[Any] = Iterator(child)
override def sql: String = {
s"rand(${if (useRandSeed) "" else child.sql})"
s"rand(${if (hideSeed) "" else child.sql})"
}
}

Expand All @@ -134,7 +134,7 @@ object Rand {
""",
since = "1.5.0")
// scalastyle:on line.size.limit
case class Randn(child: Expression, useRandSeed: Boolean = false)
case class Randn(child: Expression, hideSeed: Boolean = false)
extends RDG with ExpressionWithRandomSeed {

def this() = this(Literal(Utils.random.nextLong(), LongType), true)
Expand All @@ -155,11 +155,11 @@ case class Randn(child: Expression, useRandSeed: Boolean = false)
isNull = FalseLiteral)
}

override def freshCopy(): Randn = Randn(child)
override def freshCopy(): Randn = Randn(child, hideSeed)

override def flatArguments: Iterator[Any] = Iterator(child)
override def sql: String = {
s"randn(${if (useRandSeed) "" else child.sql})"
s"randn(${if (hideSeed) "" else child.sql})"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RandomSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation(Randn(5419823303878592871L), 0.7816815274533012)
}

test("Do not display the seed of rand/randn with no argument in output schema") {
test("SPARK-31594: Do not display the seed of rand/randn with no argument in output schema") {
assert(Rand(Literal(1L), true).sql === "rand()")
assert(Randn(Literal(1L), true).sql === "randn()")
assert(Rand(Literal(1L), false).sql === "rand(1L)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3426,7 +3426,7 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
}
}

test("Do not display the seed of rand/randn with no argument in output schema") {
test("SPARK-31594: Do not display the seed of rand/randn with no argument in output schema") {
def checkIfSeedExistsInExplain(df: DataFrame): Unit = {
val output = new java.io.ByteArrayOutputStream()
Console.withOut(output) {
Expand Down

0 comments on commit 4b1f3f2

Please sign in to comment.