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
  • Loading branch information
rxin committed Apr 7, 2014
1 parent 0307db0 commit fd11322
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 fd11322

Please sign in to comment.