dongjoon-hyun commented on a change in pull request #28342:
URL: https://github.com/apache/spark/pull/28342#discussion_r415215025
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -83,26 +93,44 @@ case class CurrentDate(timeZoneId: Option[String] = None)
override def prettyName: String = "current_date"
}
+abstract class CurrentTimestampLike() extends LeafExpression with
CodegenFallback {
+ override def foldable: Boolean = true
+ override def nullable: Boolean = false
+ override def dataType: DataType = TimestampType
+ override def eval(input: InternalRow): Any = currentTimestamp()
+}
+
/**
* Returns the current timestamp at the start of query evaluation.
* All calls of current_timestamp within the same query return the same value.
*
* There is no code generation since this expression should get constant
folded by the optimizer.
*/
@ExpressionDescription(
- usage = "_FUNC_() - Returns the current timestamp at the start of query
evaluation.",
+ usage = """
+ _FUNC_() - Returns the current timestamp at the start of query evaluation.
+
+ _FUNC_ - Returns the current timestamp at the start of query evaluation.
+ """,
+ examples = """
+ Examples:
+ > SELECT _FUNC_();
+ 2020-04-25 15:49:11.914
+ > SELECT _FUNC_;
+ 2020-04-25 15:49:11.914
+ """,
group = "datetime_funcs",
since = "1.5.0")
-case class CurrentTimestamp() extends LeafExpression with CodegenFallback {
- override def foldable: Boolean = true
- override def nullable: Boolean = false
-
- override def dataType: DataType = TimestampType
-
- override def eval(input: InternalRow): Any = currentTimestamp()
+case class CurrentTimestamp() extends CurrentTimestampLike {
+ override def prettyName: String = "current_timestamp"
+}
- override def prettyName: String =
- getTagValue(FunctionRegistry.FUNC_ALIAS).getOrElse("current_timestamp")
+@ExpressionDescription(
+ usage = "_FUNC_() - Returns the current timestamp at the start of query
evaluation.",
+ group = "datetime_funcs",
+ since = "1.5.0")
Review comment:
Oh. Sorry, I was confused. Never mind~
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]