Repository: spark
Updated Branches:
  refs/heads/master 9f48bf6b3 -> 3e7d7d6b3


[SQL] Rename MathematicalExpression UnaryMathExpression, and specify 
BinaryMathExpression's output data type as DoubleType.

Two minor changes.

cc brkyvz

Author: Reynold Xin <r...@databricks.com>

Closes #6428 from rxin/math-func-cleanup and squashes the following commits:

5910df5 [Reynold Xin] [SQL] Rename MathematicalExpression UnaryMathExpression, 
and specify BinaryMathExpression's output data type as DoubleType.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/3e7d7d6b
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/3e7d7d6b
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/3e7d7d6b

Branch: refs/heads/master
Commit: 3e7d7d6b3d6e07b52b1a138f7aa2ef628597fe05
Parents: 9f48bf6
Author: Reynold Xin <r...@databricks.com>
Authored: Wed May 27 01:13:57 2015 -0700
Committer: Reynold Xin <r...@databricks.com>
Committed: Wed May 27 01:13:57 2015 -0700

----------------------------------------------------------------------
 .../catalyst/expressions/mathfuncs/binary.scala |  9 +---
 .../catalyst/expressions/mathfuncs/unary.scala  | 46 ++++++++++----------
 2 files changed, 23 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/3e7d7d6b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathfuncs/binary.scala
----------------------------------------------------------------------
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathfuncs/binary.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathfuncs/binary.scala
index d5be446..890efc9 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathfuncs/binary.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathfuncs/binary.scala
@@ -17,7 +17,6 @@
 
 package org.apache.spark.sql.catalyst.expressions.mathfuncs
 
-import org.apache.spark.sql.catalyst.analysis.UnresolvedException
 import org.apache.spark.sql.catalyst.expressions.{ExpectsInputTypes, 
BinaryExpression, Expression, Row}
 import org.apache.spark.sql.types._
 
@@ -41,13 +40,7 @@ abstract class BinaryMathExpression(f: (Double, Double) => 
Double, name: String)
       left.dataType == right.dataType &&
       !DecimalType.isFixed(left.dataType)
 
-  override def dataType: DataType = {
-    if (!resolved) {
-      throw new UnresolvedException(this,
-        s"datatype. Can not resolve due to differing types ${left.dataType}, 
${right.dataType}")
-    }
-    left.dataType
-  }
+  override def dataType: DataType = DoubleType
 
   override def eval(input: Row): Any = {
     val evalE1 = left.eval(input)

http://git-wip-us.apache.org/repos/asf/spark/blob/3e7d7d6b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathfuncs/unary.scala
----------------------------------------------------------------------
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathfuncs/unary.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathfuncs/unary.scala
index cdcb8e2..41b4223 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathfuncs/unary.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathfuncs/unary.scala
@@ -25,7 +25,7 @@ import org.apache.spark.sql.types._
  * input format, therefore these functions extend `ExpectsInputTypes`.
  * @param name The short name of the function
  */
-abstract class MathematicalExpression(f: Double => Double, name: String)
+abstract class UnaryMathExpression(f: Double => Double, name: String)
   extends UnaryExpression with Serializable with ExpectsInputTypes {
   self: Product =>
 
@@ -46,46 +46,44 @@ abstract class MathematicalExpression(f: Double => Double, 
name: String)
   }
 }
 
-case class Acos(child: Expression) extends MathematicalExpression(math.acos, 
"ACOS")
+case class Acos(child: Expression) extends UnaryMathExpression(math.acos, 
"ACOS")
 
-case class Asin(child: Expression) extends MathematicalExpression(math.asin, 
"ASIN")
+case class Asin(child: Expression) extends UnaryMathExpression(math.asin, 
"ASIN")
 
-case class Atan(child: Expression) extends MathematicalExpression(math.atan, 
"ATAN")
+case class Atan(child: Expression) extends UnaryMathExpression(math.atan, 
"ATAN")
 
-case class Cbrt(child: Expression) extends MathematicalExpression(math.cbrt, 
"CBRT")
+case class Cbrt(child: Expression) extends UnaryMathExpression(math.cbrt, 
"CBRT")
 
-case class Ceil(child: Expression) extends MathematicalExpression(math.ceil, 
"CEIL")
+case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil, 
"CEIL")
 
-case class Cos(child: Expression) extends MathematicalExpression(math.cos, 
"COS")
+case class Cos(child: Expression) extends UnaryMathExpression(math.cos, "COS")
 
-case class Cosh(child: Expression) extends MathematicalExpression(math.cosh, 
"COSH")
+case class Cosh(child: Expression) extends UnaryMathExpression(math.cosh, 
"COSH")
 
-case class Exp(child: Expression) extends MathematicalExpression(math.exp, 
"EXP")
+case class Exp(child: Expression) extends UnaryMathExpression(math.exp, "EXP")
 
-case class Expm1(child: Expression) extends MathematicalExpression(math.expm1, 
"EXPM1")
+case class Expm1(child: Expression) extends UnaryMathExpression(math.expm1, 
"EXPM1")
 
-case class Floor(child: Expression) extends MathematicalExpression(math.floor, 
"FLOOR")
+case class Floor(child: Expression) extends UnaryMathExpression(math.floor, 
"FLOOR")
 
-case class Log(child: Expression) extends MathematicalExpression(math.log, 
"LOG")
+case class Log(child: Expression) extends UnaryMathExpression(math.log, "LOG")
 
-case class Log10(child: Expression) extends MathematicalExpression(math.log10, 
"LOG10")
+case class Log10(child: Expression) extends UnaryMathExpression(math.log10, 
"LOG10")
 
-case class Log1p(child: Expression) extends MathematicalExpression(math.log1p, 
"LOG1P")
+case class Log1p(child: Expression) extends UnaryMathExpression(math.log1p, 
"LOG1P")
 
-case class Rint(child: Expression) extends MathematicalExpression(math.rint, 
"ROUND")
+case class Rint(child: Expression) extends UnaryMathExpression(math.rint, 
"ROUND")
 
-case class Signum(child: Expression) extends 
MathematicalExpression(math.signum, "SIGNUM")
+case class Signum(child: Expression) extends UnaryMathExpression(math.signum, 
"SIGNUM")
 
-case class Sin(child: Expression) extends MathematicalExpression(math.sin, 
"SIN")
+case class Sin(child: Expression) extends UnaryMathExpression(math.sin, "SIN")
 
-case class Sinh(child: Expression) extends MathematicalExpression(math.sinh, 
"SINH")
+case class Sinh(child: Expression) extends UnaryMathExpression(math.sinh, 
"SINH")
 
-case class Tan(child: Expression) extends MathematicalExpression(math.tan, 
"TAN")
+case class Tan(child: Expression) extends UnaryMathExpression(math.tan, "TAN")
 
-case class Tanh(child: Expression) extends MathematicalExpression(math.tanh, 
"TANH")
+case class Tanh(child: Expression) extends UnaryMathExpression(math.tanh, 
"TANH")
 
-case class ToDegrees(child: Expression) 
-  extends MathematicalExpression(math.toDegrees, "DEGREES")
+case class ToDegrees(child: Expression) extends 
UnaryMathExpression(math.toDegrees, "DEGREES")
 
-case class ToRadians(child: Expression) 
-  extends MathematicalExpression(math.toRadians, "RADIANS")
+case class ToRadians(child: Expression) extends 
UnaryMathExpression(math.toRadians, "RADIANS")


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to