Skip to content

Commit

Permalink
Added eval for Rand (without any support for user-defined seed).
Browse files Browse the repository at this point in the history
Author: Reynold Xin <[email protected]>

Closes #349 from rxin/rand and squashes the following commits:

fd11322 [Reynold Xin] Added eval for Rand (without any support for user-defined seed).
  • Loading branch information
rxin committed Apr 8, 2014
1 parent 55dfd5d commit 31e6fff
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@

package org.apache.spark.sql.catalyst.expressions

import java.util.Random
import org.apache.spark.sql.catalyst.types.DoubleType


case object Rand extends LeafExpression {
def dataType = DoubleType
def nullable = false
def references = Set.empty
override def dataType = DoubleType
override def nullable = false
override def references = Set.empty

private[this] lazy val rand = new Random

override def eval(input: Row = null) = rand.nextDouble().asInstanceOf[EvaluatedType]

override def toString = "RAND()"
}

0 comments on commit 31e6fff

Please sign in to comment.