You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by hv...@apache.org on 2018/03/27 12:49:55 UTC
spark git commit: [SPARK-23794][SQL] Make UUID as stateful expression
Repository: spark
Updated Branches:
refs/heads/master 3e778f5a9 -> 35997b59f
[SPARK-23794][SQL] Make UUID as stateful expression
## What changes were proposed in this pull request?
The UUID() expression is stateful and should implement the `Stateful` trait instead of the `Nondeterministic` trait.
## How was this patch tested?
Added test.
Author: Liang-Chi Hsieh <vi...@gmail.com>
Closes #20912 from viirya/SPARK-23794.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/35997b59
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/35997b59
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/35997b59
Branch: refs/heads/master
Commit: 35997b59f3116830af06b3d40a7675ef0dbf7091
Parents: 3e778f5
Author: Liang-Chi Hsieh <vi...@gmail.com>
Authored: Tue Mar 27 14:49:50 2018 +0200
Committer: Herman van Hovell <hv...@databricks.com>
Committed: Tue Mar 27 14:49:50 2018 +0200
----------------------------------------------------------------------
.../scala/org/apache/spark/sql/catalyst/expressions/misc.scala | 4 +++-
.../spark/sql/catalyst/expressions/MiscExpressionsSuite.scala | 6 ++++++
2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/35997b59/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/misc.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/misc.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/misc.scala
index ec93620..a390f8e 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/misc.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/misc.scala
@@ -123,7 +123,7 @@ case class CurrentDatabase() extends LeafExpression with Unevaluable {
46707d92-02f4-4817-8116-a4c3b23e6266
""")
// scalastyle:on line.size.limit
-case class Uuid(randomSeed: Option[Long] = None) extends LeafExpression with Nondeterministic {
+case class Uuid(randomSeed: Option[Long] = None) extends LeafExpression with Stateful {
def this() = this(None)
@@ -152,4 +152,6 @@ case class Uuid(randomSeed: Option[Long] = None) extends LeafExpression with Non
ev.copy(code = s"final UTF8String ${ev.value} = $randomGen.getNextUUIDUTF8String();",
isNull = "false")
}
+
+ override def freshCopy(): Uuid = Uuid(randomSeed)
}
http://git-wip-us.apache.org/repos/asf/spark/blob/35997b59/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MiscExpressionsSuite.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MiscExpressionsSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MiscExpressionsSuite.scala
index 3383d42..b6c2693 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MiscExpressionsSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MiscExpressionsSuite.scala
@@ -59,6 +59,12 @@ class MiscExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
evaluateWithGeneratedMutableProjection(Uuid(seed2)))
assert(evaluateWithUnsafeProjection(Uuid(seed1)) !==
evaluateWithUnsafeProjection(Uuid(seed2)))
+
+ val uuid = Uuid(seed1)
+ assert(uuid.fastEquals(uuid))
+ assert(!uuid.fastEquals(Uuid(seed1)))
+ assert(!uuid.fastEquals(uuid.freshCopy()))
+ assert(!uuid.fastEquals(Uuid(seed2)))
}
test("PrintToStderr") {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org