Skip to content

Commit

Permalink
[SPARK-32729][SQL][DOCS] Add missing since version for math functions
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

Add missing since version for math functions, including
SPARK-8223 shiftright/shiftleft
SPARK-8215 pi
SPARK-8212 e
SPARK-6829 sin/asin/sinh/cos/acos/cosh/tan/atan/tanh/ceil/floor/rint/cbrt/signum/isignum/Fsignum/Lsignum/degrees/radians/log/log10/log1p/exp/expm1/pow/hypot/atan2
SPARK-8209 conv
SPARK-8213 factorial
SPARK-20751 cot
SPARK-2813 sqrt
SPARK-8227 unhex
SPARK-8218 log(a,b)
SPARK-8207 bin
SPARK-8214 hex
SPARK-8206 round
SPARK-14614 bround

### Why are the changes needed?

fix SQL docs
### Does this PR introduce _any_ user-facing change?

yes, doc updated

### How was this patch tested?

passing doc generation.

Closes #29571 from yaooqinn/minor.

Authored-by: Kent Yao <yaooqinn@hotmail.com>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
  • Loading branch information
yaooqinn authored and HyukjinKwon committed Aug 28, 2020
1 parent c3b9404 commit 0626901
Showing 1 changed file with 80 additions and 40 deletions.
Expand Up @@ -147,7 +147,8 @@ abstract class BinaryMathExpression(f: (Double, Double) => Double, name: String)
Examples:
> SELECT _FUNC_();
2.718281828459045
""")
""",
since = "1.5.0")
case class EulerNumber() extends LeafMathExpression(math.E, "E")

/**
Expand All @@ -160,7 +161,8 @@ case class EulerNumber() extends LeafMathExpression(math.E, "E")
Examples:
> SELECT _FUNC_();
3.141592653589793
""")
""",
since = "1.5.0")
case class Pi() extends LeafMathExpression(math.Pi, "PI")

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -180,7 +182,8 @@ case class Pi() extends LeafMathExpression(math.Pi, "PI")
0.0
> SELECT _FUNC_(2);
NaN
""")
""",
since = "1.4.0")
case class Acos(child: Expression) extends UnaryMathExpression(math.acos, "ACOS")

@ExpressionDescription(
Expand All @@ -194,7 +197,8 @@ case class Acos(child: Expression) extends UnaryMathExpression(math.acos, "ACOS"
0.0
> SELECT _FUNC_(2);
NaN
""")
""",
since = "1.4.0")
case class Asin(child: Expression) extends UnaryMathExpression(math.asin, "ASIN")

@ExpressionDescription(
Expand All @@ -206,7 +210,8 @@ case class Asin(child: Expression) extends UnaryMathExpression(math.asin, "ASIN"
Examples:
> SELECT _FUNC_(0);
0.0
""")
""",
since = "1.4.0")
case class Atan(child: Expression) extends UnaryMathExpression(math.atan, "ATAN")

@ExpressionDescription(
Expand All @@ -215,7 +220,8 @@ case class Atan(child: Expression) extends UnaryMathExpression(math.atan, "ATAN"
Examples:
> SELECT _FUNC_(27.0);
3.0
""")
""",
since = "1.4.0")
case class Cbrt(child: Expression) extends UnaryMathExpression(math.cbrt, "CBRT")

@ExpressionDescription(
Expand All @@ -226,7 +232,8 @@ case class Cbrt(child: Expression) extends UnaryMathExpression(math.cbrt, "CBRT"
0
> SELECT _FUNC_(5);
5
""")
""",
since = "1.4.0")
case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil, "CEIL") {
override def dataType: DataType = child.dataType match {
case dt @ DecimalType.Fixed(_, 0) => dt
Expand Down Expand Up @@ -268,7 +275,8 @@ case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil, "CEIL"
Examples:
> SELECT _FUNC_(0);
1.0
""")
""",
since = "1.4.0")
case class Cos(child: Expression) extends UnaryMathExpression(math.cos, "COS")

@ExpressionDescription(
Expand All @@ -284,7 +292,8 @@ case class Cos(child: Expression) extends UnaryMathExpression(math.cos, "COS")
Examples:
> SELECT _FUNC_(0);
1.0
""")
""",
since = "1.4.0")
case class Cosh(child: Expression) extends UnaryMathExpression(math.cosh, "COSH")

@ExpressionDescription(
Expand Down Expand Up @@ -322,7 +331,8 @@ case class Acosh(child: Expression)
4
> SELECT _FUNC_(-10, 16, -10);
-16
""")
""",
since = "1.5.0")
case class Conv(numExpr: Expression, fromBaseExpr: Expression, toBaseExpr: Expression)
extends TernaryExpression with ImplicitCastInputTypes with NullIntolerant {

Expand Down Expand Up @@ -357,7 +367,8 @@ case class Conv(numExpr: Expression, fromBaseExpr: Expression, toBaseExpr: Expre
Examples:
> SELECT _FUNC_(0);
1.0
""")
""",
since = "1.4.0")
case class Exp(child: Expression) extends UnaryMathExpression(StrictMath.exp, "EXP") {
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
defineCodeGen(ctx, ev, c => s"java.lang.StrictMath.exp($c)")
Expand All @@ -370,7 +381,8 @@ case class Exp(child: Expression) extends UnaryMathExpression(StrictMath.exp, "E
Examples:
> SELECT _FUNC_(0);
0.0
""")
""",
since = "1.4.0")
case class Expm1(child: Expression) extends UnaryMathExpression(StrictMath.expm1, "EXPM1") {
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
defineCodeGen(ctx, ev, c => s"java.lang.StrictMath.expm1($c)")
Expand All @@ -385,7 +397,8 @@ case class Expm1(child: Expression) extends UnaryMathExpression(StrictMath.expm1
-1
> SELECT _FUNC_(5);
5
""")
""",
since = "1.4.0")
case class Floor(child: Expression) extends UnaryMathExpression(math.floor, "FLOOR") {
override def dataType: DataType = child.dataType match {
case dt @ DecimalType.Fixed(_, 0) => dt
Expand Down Expand Up @@ -451,7 +464,8 @@ object Factorial {
Examples:
> SELECT _FUNC_(5);
120
""")
""",
since = "1.5.0")
case class Factorial(child: Expression)
extends UnaryExpression with ImplicitCastInputTypes with NullIntolerant {

Expand Down Expand Up @@ -491,7 +505,8 @@ case class Factorial(child: Expression)
Examples:
> SELECT _FUNC_(1);
0.0
""")
""",
since = "1.4.0")
case class Log(child: Expression) extends UnaryLogExpression(StrictMath.log, "LOG") {
override def prettyName: String = getTagValue(FunctionRegistry.FUNC_ALIAS).getOrElse("ln")
}
Expand All @@ -502,7 +517,8 @@ case class Log(child: Expression) extends UnaryLogExpression(StrictMath.log, "LO
Examples:
> SELECT _FUNC_(2);
1.0
""")
""",
since = "1.4.0")
case class Log2(child: Expression)
extends UnaryLogExpression((x: Double) => StrictMath.log(x) / StrictMath.log(2), "LOG2") {
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
Expand All @@ -524,7 +540,8 @@ case class Log2(child: Expression)
Examples:
> SELECT _FUNC_(10);
1.0
""")
""",
since = "1.4.0")
case class Log10(child: Expression) extends UnaryLogExpression(StrictMath.log10, "LOG10")

@ExpressionDescription(
Expand All @@ -533,7 +550,8 @@ case class Log10(child: Expression) extends UnaryLogExpression(StrictMath.log10,
Examples:
> SELECT _FUNC_(0);
0.0
""")
""",
since = "1.4.0")
case class Log1p(child: Expression) extends UnaryLogExpression(StrictMath.log1p, "LOG1P") {
protected override val yAsymptote: Double = -1.0
}
Expand All @@ -545,7 +563,8 @@ case class Log1p(child: Expression) extends UnaryLogExpression(StrictMath.log1p,
Examples:
> SELECT _FUNC_(12.3456);
12.0
""")
""",
since = "1.4.0")
// scalastyle:on line.size.limit
case class Rint(child: Expression) extends UnaryMathExpression(math.rint, "ROUND") {
override def funcName: String = "rint"
Expand All @@ -558,7 +577,8 @@ case class Rint(child: Expression) extends UnaryMathExpression(math.rint, "ROUND
Examples:
> SELECT _FUNC_(40);
1.0
""")
""",
since = "1.4.0")
case class Signum(child: Expression) extends UnaryMathExpression(math.signum, "SIGNUM")

@ExpressionDescription(
Expand All @@ -571,7 +591,8 @@ case class Signum(child: Expression) extends UnaryMathExpression(math.signum, "S
Examples:
> SELECT _FUNC_(0);
0.0
""")
""",
since = "1.4.0")
case class Sin(child: Expression) extends UnaryMathExpression(math.sin, "SIN")

@ExpressionDescription(
Expand All @@ -586,7 +607,8 @@ case class Sin(child: Expression) extends UnaryMathExpression(math.sin, "SIN")
Examples:
> SELECT _FUNC_(0);
0.0
""")
""",
since = "1.4.0")
case class Sinh(child: Expression) extends UnaryMathExpression(math.sinh, "SINH")

@ExpressionDescription(
Expand Down Expand Up @@ -616,7 +638,8 @@ case class Asinh(child: Expression)
Examples:
> SELECT _FUNC_(4);
2.0
""")
""",
since = "1.1.1")
case class Sqrt(child: Expression) extends UnaryMathExpression(math.sqrt, "SQRT")

@ExpressionDescription(
Expand All @@ -631,7 +654,8 @@ case class Sqrt(child: Expression) extends UnaryMathExpression(math.sqrt, "SQRT"
Examples:
> SELECT _FUNC_(0);
0.0
""")
""",
since = "1.4.0")
case class Tan(child: Expression) extends UnaryMathExpression(math.tan, "TAN")

@ExpressionDescription(
Expand All @@ -646,7 +670,8 @@ case class Tan(child: Expression) extends UnaryMathExpression(math.tan, "TAN")
Examples:
> SELECT _FUNC_(1);
0.6420926159343306
""")
""",
since = "2.3.0")
case class Cot(child: Expression)
extends UnaryMathExpression((x: Double) => 1 / math.tan(x), "COT") {
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
Expand All @@ -667,7 +692,8 @@ case class Cot(child: Expression)
Examples:
> SELECT _FUNC_(0);
0.0
""")
""",
since = "1.4.0")
case class Tanh(child: Expression) extends UnaryMathExpression(math.tanh, "TANH")

@ExpressionDescription(
Expand Down Expand Up @@ -702,7 +728,8 @@ case class Atanh(child: Expression)
Examples:
> SELECT _FUNC_(3.141592653589793);
180.0
""")
""",
since = "1.4.0")
case class ToDegrees(child: Expression) extends UnaryMathExpression(math.toDegrees, "DEGREES") {
override def funcName: String = "toDegrees"
}
Expand All @@ -717,7 +744,8 @@ case class ToDegrees(child: Expression) extends UnaryMathExpression(math.toDegre
Examples:
> SELECT _FUNC_(180);
3.141592653589793
""")
""",
since = "1.4.0")
case class ToRadians(child: Expression) extends UnaryMathExpression(math.toRadians, "RADIANS") {
override def funcName: String = "toRadians"
}
Expand All @@ -733,7 +761,8 @@ case class ToRadians(child: Expression) extends UnaryMathExpression(math.toRadia
1111111111111111111111111111111111111111111111111111111111110011
> SELECT _FUNC_(13.3);
1101
""")
""",
since = "1.5.0")
// scalastyle:on line.size.limit
case class Bin(child: Expression)
extends UnaryExpression with ImplicitCastInputTypes with NullIntolerant with Serializable {
Expand Down Expand Up @@ -834,7 +863,8 @@ object Hex {
11
> SELECT _FUNC_('Spark SQL');
537061726B2053514C
""")
""",
since = "1.5.0")
case class Hex(child: Expression)
extends UnaryExpression with ImplicitCastInputTypes with NullIntolerant {

Expand Down Expand Up @@ -870,7 +900,8 @@ case class Hex(child: Expression)
Examples:
> SELECT decode(_FUNC_('537061726B2053514C'), 'UTF-8');
Spark SQL
""")
""",
since = "1.5.0")
case class Unhex(child: Expression)
extends UnaryExpression with ImplicitCastInputTypes with NullIntolerant {

Expand Down Expand Up @@ -915,7 +946,8 @@ case class Unhex(child: Expression)
Examples:
> SELECT _FUNC_(0, 0);
0.0
""")
""",
since = "1.4.0")
case class Atan2(left: Expression, right: Expression)
extends BinaryMathExpression(math.atan2, "ATAN2") {

Expand All @@ -935,7 +967,8 @@ case class Atan2(left: Expression, right: Expression)
Examples:
> SELECT _FUNC_(2, 3);
8.0
""")
""",
since = "1.4.0")
case class Pow(left: Expression, right: Expression)
extends BinaryMathExpression(StrictMath.pow, "POWER") {
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
Expand All @@ -956,7 +989,8 @@ case class Pow(left: Expression, right: Expression)
Examples:
> SELECT _FUNC_(2, 1);
4
""")
""",
since = "1.5.0")
case class ShiftLeft(left: Expression, right: Expression)
extends BinaryExpression with ImplicitCastInputTypes with NullIntolerant {

Expand Down Expand Up @@ -990,7 +1024,8 @@ case class ShiftLeft(left: Expression, right: Expression)
Examples:
> SELECT _FUNC_(4, 1);
2
""")
""",
since = "1.5.0")
case class ShiftRight(left: Expression, right: Expression)
extends BinaryExpression with ImplicitCastInputTypes with NullIntolerant {

Expand Down Expand Up @@ -1024,7 +1059,8 @@ case class ShiftRight(left: Expression, right: Expression)
Examples:
> SELECT _FUNC_(4, 1);
2
""")
""",
since = "1.5.0")
case class ShiftRightUnsigned(left: Expression, right: Expression)
extends BinaryExpression with ImplicitCastInputTypes with NullIntolerant {

Expand All @@ -1051,7 +1087,8 @@ case class ShiftRightUnsigned(left: Expression, right: Expression)
Examples:
> SELECT _FUNC_(3, 4);
5.0
""")
""",
since = "1.4.0")
case class Hypot(left: Expression, right: Expression)
extends BinaryMathExpression(math.hypot, "HYPOT")

Expand All @@ -1068,7 +1105,8 @@ case class Hypot(left: Expression, right: Expression)
Examples:
> SELECT _FUNC_(10, 100);
2.0
""")
""",
since = "1.5.0")
case class Logarithm(left: Expression, right: Expression)
extends BinaryMathExpression((c1, c2) => StrictMath.log(c2) / StrictMath.log(c1), "LOG") {

Expand Down Expand Up @@ -1298,7 +1336,8 @@ abstract class RoundBase(child: Expression, scale: Expression,
Examples:
> SELECT _FUNC_(2.5, 0);
3
""")
""",
since = "1.5.0")
// scalastyle:on line.size.limit
case class Round(child: Expression, scale: Expression)
extends RoundBase(child, scale, BigDecimal.RoundingMode.HALF_UP, "ROUND_HALF_UP")
Expand All @@ -1318,7 +1357,8 @@ case class Round(child: Expression, scale: Expression)
Examples:
> SELECT _FUNC_(2.5, 0);
2
""")
""",
since = "2.0.0")
// scalastyle:on line.size.limit
case class BRound(child: Expression, scale: Expression)
extends RoundBase(child, scale, BigDecimal.RoundingMode.HALF_EVEN, "ROUND_HALF_EVEN")
Expand Down

0 comments on commit 0626901

Please sign in to comment.