Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/15513#discussion_r84574009
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala
---
@@ -384,71 +502,157 @@ case class Log2(child: Expression)
}
@ExpressionDescription(
- usage = "_FUNC_(x) - Returns the logarithm of x with base 10.",
- extended = "> SELECT _FUNC_(10);\n 1.0")
+ usage = "_FUNC_(expr) - Returns the logarithm of expr with base 10.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(10);
+ 1.0
+ """)
case class Log10(child: Expression) extends UnaryLogExpression(math.log10,
"LOG10")
@ExpressionDescription(
- usage = "_FUNC_(x) - Returns log(1 + x).",
- extended = "> SELECT _FUNC_(0);\n 0.0")
+ usage = "_FUNC_(expr) - Returns log(1 + expr).",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(0);
+ 0.0
+ """)
case class Log1p(child: Expression) extends UnaryLogExpression(math.log1p,
"LOG1P") {
protected override val yAsymptote: Double = -1.0
}
+// scalastyle:off line.size.limit
@ExpressionDescription(
- usage = "_FUNC_(x, d) - Return the rounded x at d decimal places.",
- extended = "> SELECT _FUNC_(12.3456, 1);\n 12.3")
+ usage = "_FUNC_(expr) - Returns the double value that is closest in
value to the argument and is equal to a mathematical integer.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(12.3456);
+ 12.0
+ """)
+// scalastyle:on line.size.limit
case class Rint(child: Expression) extends UnaryMathExpression(math.rint,
"ROUND") {
override def funcName: String = "rint"
}
@ExpressionDescription(
- usage = "_FUNC_(x) - Returns the sign of x.",
- extended = "> SELECT _FUNC_(40);\n 1.0")
+ usage = "_FUNC_(expr) - Returns the sign of expr.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(40);
+ 1.0
+ """)
case class Signum(child: Expression) extends
UnaryMathExpression(math.signum, "SIGNUM")
@ExpressionDescription(
- usage = "_FUNC_(x) - Returns the sine of x.",
- extended = "> SELECT _FUNC_(0);\n 0.0")
+ usage = "_FUNC_(expr) - Returns the sine of expr.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(0);
+ 0.0
+ """)
case class Sin(child: Expression) extends UnaryMathExpression(math.sin,
"SIN")
@ExpressionDescription(
- usage = "_FUNC_(x) - Returns the hyperbolic sine of x.",
- extended = "> SELECT _FUNC_(0);\n 0.0")
+ usage = "_FUNC_(expr) - Returns the hyperbolic sine of expr.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(0);
+ 0.0
+ """)
case class Sinh(child: Expression) extends UnaryMathExpression(math.sinh,
"SINH")
@ExpressionDescription(
- usage = "_FUNC_(x) - Returns the square root of x.",
- extended = "> SELECT _FUNC_(4);\n 2.0")
+ usage = "_FUNC_(expr) - Returns the square root of expr.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(4);
+ 2.0
+ """)
case class Sqrt(child: Expression) extends UnaryMathExpression(math.sqrt,
"SQRT")
@ExpressionDescription(
- usage = "_FUNC_(x) - Returns the tangent of x.",
- extended = "> SELECT _FUNC_(0);\n 0.0")
+ usage = "_FUNC_(expr) - Returns the tangent of expr.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(0);
+ 0.0
+ """)
case class Tan(child: Expression) extends UnaryMathExpression(math.tan,
"TAN")
@ExpressionDescription(
- usage = "_FUNC_(x) - Returns the hyperbolic tangent of x.",
- extended = "> SELECT _FUNC_(0);\n 0.0")
+ usage = "_FUNC_(expr) - Returns the hyperbolic tangent of expr.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(0);
+ 0.0
+ """)
case class Tanh(child: Expression) extends UnaryMathExpression(math.tanh,
"TANH")
@ExpressionDescription(
- usage = "_FUNC_(x) - Converts radians to degrees.",
- extended = "> SELECT _FUNC_(3.141592653589793);\n 180.0")
+ usage = "_FUNC_(expr) - Converts radians to degrees.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(3.141592653589793);
+ 180.0
+ """)
case class ToDegrees(child: Expression) extends
UnaryMathExpression(math.toDegrees, "DEGREES") {
override def funcName: String = "toDegrees"
}
@ExpressionDescription(
- usage = "_FUNC_(x) - Converts degrees to radians.",
- extended = "> SELECT _FUNC_(180);\n 3.141592653589793")
+ usage = "_FUNC_(expr) - Converts degrees to radians.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
+
+ Examples:
+ > SELECT _FUNC_(180);
+ 3.141592653589793
+ """)
case class ToRadians(child: Expression) extends
UnaryMathExpression(math.toRadians, "RADIANS") {
override def funcName: String = "toRadians"
}
@ExpressionDescription(
- usage = "_FUNC_(x) - Returns x in binary.",
- extended = "> SELECT _FUNC_(13);\n '1101'")
+ usage = "_FUNC_(expr) - Returns expr in binary.",
+ extended = """
+ Arguments:
+ expr - a numeric expression.
--- End diff --
For several of these functions like this one and the base-changing
functions, is it important to say that they need an integer argument or else
the value will be truncated to an integer? I don't know what the standard is
here. BIN(13.3) actually returns a value, equal to BIN(13).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]