grundprinzip commented on code in PR #38270:
URL: https://github.com/apache/spark/pull/38270#discussion_r996449640
##########
python/pyspark/sql/connect/column.py:
##########
@@ -19,18 +19,59 @@
import pyspark.sql.connect.proto as proto
+
from pyspark.sql.connect._typing import PrimitiveType
if TYPE_CHECKING:
from pyspark.sql.connect.client import RemoteSparkSession
import pyspark.sql.connect.proto as proto
+def _bin_op(
+ name: str, doc: str = "binary function", reverse: bool = False
+) -> Callable[["ColumnRef", Any], "Expression"]:
+ def _(self: "ColumnRef", other: Any) -> "Expression":
+ if isinstance(other, get_args(PrimitiveType)):
+ other = LiteralExpression(other)
+ if not reverse:
+ return ScalarFunctionExpression(name, self, other)
+ else:
+ return ScalarFunctionExpression(name, other, self)
+
+ return _
+
+
class Expression(object):
"""
Expression base class.
"""
+ __gt__ = _bin_op(">")
Review Comment:
Without this change the different expressions are not combinable. Until now
only column references were combinable but actually all column expressions
should be.
--
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]