You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "snuyanzin (via GitHub)" <gi...@apache.org> on 2025/01/07 08:33:25 UTC
Re: [PR] [FLINK-36941][docs] Update DATE_FORMAT Doc and Python Tests in 1.20 [flink]
snuyanzin commented on code in PR #25874:
URL: https://github.com/apache/flink/pull/25874#discussion_r1905081855
##########
flink-python/pyflink/table/expressions.py:
##########
@@ -350,14 +350,21 @@ def temporal_overlaps(left_time_point,
def date_format(timestamp, format) -> Expression:
"""
Formats a timestamp as a string using a specified format.
- The format must be compatible with MySQL's date formatting syntax as used by the
- date_parse function.
- For example `date_format(col("time"), "%Y, %d %M")` results in strings formatted as
- "2017, 05 May".
+ Supported functions:
+ 1. date_format(TIMESTAMP, STRING) -> STRING
+ Converts timestamp to a string, using a format string.
+ The format string is compatible with Java's DateTimeFormatter.
+ 2. date_format(STRING, STRING) -> STRING
+ Converts timestamp string, using a format string.
+ The format string is compatible with Java's SimpleDateFormat.
+
+ Example:
+ ::
+
+ >>> table.select(date_format(to_timestamp('2020-04-15'), "yyyy/MM/dd"))
+ >>> table.select(date_format("2020-04-15", "MM/dd/yyyy"))
Review Comment:
IIUC it works only with timestamp string like
```sql
SELECT date_format('2020-04-15 12:12:12', 'MM/dd/yyyy');
```
and for the expression from this PR like
```python
table.select(date_format("2020-04-15", "MM/dd/yyyy"))
```
it will return `null`
I think it is better to provide examples which could return some meaningful output
WDYT?
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org