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 @@ -81,6 +81,7 @@ trait ExpressionWithRandomSeed extends Expression {

private[catalyst] object ExpressionWithRandomSeed {
def expressionToSeed(e: Expression, source: String): Option[Long] = e match {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this helper function is only used in uuid and shuffle for now

case IntegerLiteral(seed) => Some(seed)
case LongLiteral(seed) => Some(seed)
case Literal(null, _) => None
case _ => throw QueryCompilationErrors.invalidRandomSeedParameter(source, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2293,6 +2293,14 @@ class CollectionExpressionsSuite
evaluateWithMutableProjection(Shuffle(ai0, seed2)))
assert(evaluateWithUnsafeProjection(Shuffle(ai0, seed1)) !==
evaluateWithUnsafeProjection(Shuffle(ai0, seed2)))

val seed3 = Literal.create(r.nextInt())
assert(evaluateWithoutCodegen(new Shuffle(ai0, seed3)) ===
evaluateWithoutCodegen(new Shuffle(ai0, seed3)))
assert(evaluateWithMutableProjection(new Shuffle(ai0, seed3)) ===
evaluateWithMutableProjection(new Shuffle(ai0, seed3)))
assert(evaluateWithUnsafeProjection(new Shuffle(ai0, seed3)) ===
evaluateWithUnsafeProjection(new Shuffle(ai0, seed3)))
}

test("Array Except") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ class MiscExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
evaluateWithMutableProjection(Uuid(seed2)))
assert(evaluateWithUnsafeProjection(Uuid(seed1)) !==
evaluateWithUnsafeProjection(Uuid(seed2)))

val seed3 = Literal.create(r.nextInt())
assert(evaluateWithoutCodegen(new Uuid(seed3)) === evaluateWithoutCodegen(new Uuid(seed3)))
assert(evaluateWithMutableProjection(new Uuid(seed3)) ===
evaluateWithMutableProjection(new Uuid(seed3)))
assert(evaluateWithUnsafeProjection(new Uuid(seed3)) ===
evaluateWithUnsafeProjection(new Uuid(seed3)))
}

test("PrintToStderr") {
Expand Down