File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -131,18 +131,21 @@ def func(df: SparkLikeLazyFrame) -> list[Column]:
131131 def mean_horizontal (self , * exprs : SparkLikeExpr ) -> SparkLikeExpr :
132132 def func (df : SparkLikeLazyFrame ) -> list [Column ]:
133133 cols = [c for _expr in exprs for c in _expr (df )]
134+ F = exprs [0 ]._F # noqa: N806
135+ # PySpark before 3.5 doesn't have `try_divide`, SQLFrame doesn't have it.
136+ divide = getattr (F , "try_divide" , operator .truediv )
134137 return [
135- (
138+ divide (
136139 reduce (
137140 operator .add , (df ._F .coalesce (col , df ._F .lit (0 )) for col in cols )
138- )
139- / reduce (
141+ ),
142+ reduce (
140143 operator .add ,
141144 (
142145 col .isNotNull ().cast (df ._native_dtypes .IntegerType ())
143146 for col in cols
144147 ),
145- )
148+ ),
146149 )
147150 ]
148151
You can’t perform that action at this time.
0 commit comments