amaliujia commented on code in PR #38806:
URL: https://github.com/apache/spark/pull/38806#discussion_r1033199435
##########
python/pyspark/sql/connect/column.py:
##########
@@ -30,53 +30,34 @@
def _bin_op(
name: str, doc: str = "binary function", reverse: bool = False
-) -> Callable[["Column", Any], "Expression"]:
- def _(self: "Column", other: Any) -> "Expression":
+) -> Callable[["Column", Any], "Column"]:
+ def _(self: "Column", other: Any) -> "Column":
from pyspark.sql.connect._typing import PrimitiveType
+ from pyspark.sql.connect.functions import lit
if isinstance(other, get_args(PrimitiveType)):
- other = LiteralExpression(other)
+ other = lit(other)
if not reverse:
- return ScalarFunctionExpression(name, self, other)
+ return scalar_function(name, self, other)
else:
- return ScalarFunctionExpression(name, other, self)
+ return scalar_function(name, other, self)
return _
+def scalar_function(op: str, *args: "Column") -> "Column":
+ return Column(ScalarFunctionExpression(op, *args))
+
+
+def sql_expression(expr: str) -> "Column":
+ return Column(SQLExpression(expr))
+
+
class Expression(object):
Review Comment:
I tried this but hit a cycle import issue so I stopped. Maybe that is
solvable but didn't spend too much time on that.
If you think this is very important I can go back to check what was wrong.
--
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]