timsaucer commented on code in PR #1467:
URL:
https://github.com/apache/datafusion-python/pull/1467#discussion_r3029902701
##########
python/datafusion/functions.py:
##########
@@ -1970,6 +1982,15 @@ def to_char(arg: Expr, formatter: Expr) -> Expr:
return Expr(f.to_char(arg.expr, formatter.expr))
+def date_format(arg: Expr, formatter: Expr) -> Expr:
+ """Returns a string representation of a date, time, timestamp or duration.
+
+ See Also:
+ This is an alias for :py:func:`to_char`.
+ """
+ return to_char(arg, formatter)
+
+
Review Comment:
I was looking at this. It's true that we do get the alias via SQL, but we
actually will get this same behavior for all aliases. This impacts our existing
things like:
```python
from datafusion import SessionContext, functions as F, col
import pyarrow as pa
import numpy as np
data = [[1.0, 2.0, 3.0, 3.0], [4.0, 5.0, 3.0], [6.0]]
ctx = SessionContext()
batch = pa.RecordBatch.from_arrays([np.array(data, dtype=object)],
names=["arr"])
df = ctx.create_dataframe([[batch]])
df.select(
F.list_sort(col("arr")),
).show()
```
Results in:
```
DataFrame()
+----------------------------------------------------------------------------------+
| array_sort(c3b76956cf32e4475aab41190fde60912.arr,Utf8("ASC"),Utf8("NULLS
LAST")) |
+----------------------------------------------------------------------------------+
| [1.0, 2.0, 3.0, 3.0]
|
| [3.0, 4.0, 5.0]
|
| [6.0]
|
+----------------------------------------------------------------------------------+
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]