HyukjinKwon opened a new pull request #24259: [SPARK-27328][SQL] Create 
'deprecate' property in ExpressionDescription for SQL function documentation
URL: https://github.com/apache/spark/pull/24259
 
 
   ## What changes were proposed in this pull request?
   
   This PR proposes to two things:
   
   1. Add `deprecated` field to `ExpressionDescription` so that it can be shown 
in our SQL function documentation 
(https://spark.apache.org/docs/latest/api/sql/), and it can be shown via 
`DESCRIBE FUNCTION EXTENDED`.
   
   2. While I am here, add some more restrictions for `note()` and `since()`. 
Looks some documentations are broken due to malformed `note`:
   
       ![Screen Shot 2019-03-31 at 3 00 53 
PM](https://user-images.githubusercontent.com/6477701/55285518-a3e88500-53c8-11e9-9e99-41d857794fbe.png)
   
       It should start with 4 spaces and end with a newline. I added some 
asserts, and fixed the instances together while I am here. This is technically 
a breaking change but I think it's too trivial to note somewhere (and we're in 
Spark 3.0.0).
   
   ### Usage for this `deprecated` property.
   
   If we add a `deprecated` field as below (4 leading spaces and a newline at 
the end):
   
   ```diff
   diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
   index 833b2f03f66..3cda9899aa5 100644
   --- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
   +++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
   @@ -1016,10 +1016,7 @@ case class TimeAdd(start: Expression, interval: 
Expression, timeZoneId: Option[S
          > SELECT from_utc_timestamp('2016-08-31', 'Asia/Seoul');
           2016-08-31 09:00:00
      """,
   -  since = "1.5.0")
   +  since = "1.5.0",
   +  deprecated = """
   +    Deprecated since 3.0.0. See SPARK-25496.
   +  """)
    // scalastyle:on line.size.limit
    case class FromUTCTimestamp(left: Expression, right: Expression)
      extends BinaryExpression with ImplicitCastInputTypes {
   ```
   
   **SQL documentation is shown as below:**
   
   ![Screen Shot 2019-03-31 at 3 07 31 
PM](https://user-images.githubusercontent.com/6477701/55285537-2113fa00-53c9-11e9-9932-f5693a03332d.png)
   
   **`DESCRIBE FUNCTION EXTENDED from_utc_timestamp;`**:
   
   ```
   Function: from_utc_timestamp
   Class: org.apache.spark.sql.catalyst.expressions.FromUTCTimestamp
   Usage: from_utc_timestamp(timestamp, timezone) - Given a timestamp like 
'2017-07-14 02:40:00.0', interprets it as a time in UTC, and renders that time 
as a timestamp in the given time zone. For example, 'GMT+1' would yield 
'2017-07-14 03:40:00.0'.
   Extended Usage:
       Examples:
         > SELECT from_utc_timestamp('2016-08-31', 'Asia/Seoul');
          2016-08-31 09:00:00
   
       Since: 1.5.0
   
       Deprecated:
         Deprecated since 3.0.0. See SPARK-25496.
   
   ```
   
   
   ## How was this patch tested?
   
   Manually tested via:
   
   - For documentation verification:
   
       ```
       $ cd sql
       $ sh create-docs.sh
       ```
   
   - For checking description:
   
       ```
       $ ./bin/spark-sql
       ```
       ```
       spark-sql> DESCRIBE FUNCTION EXTENDED from_utc_timestamp;
       ```
   

----------------------------------------------------------------
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]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to