[SPARK-36104][PYTHON] Manage InternalField in DataTypeOps.neg/abs
### What changes were proposed in this pull request?
Manage InternalField for DataTypeOps.neg/abs.
### Why are the changes needed?
The spark data type and nullability must be the same as the original when DataTypeOps.neg/abs.
We should manage InternalField for this case.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Unit tests.
Closes #33307 from xinrong-databricks/internalField.
Authored-by: Xinrong Meng <xinrong.meng@databricks.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
(cherry picked from commit 5afc27f899
)
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
This commit is contained in:
parent
8d9758ee46
commit
eae79dd31b
|
@ -123,10 +123,12 @@ class NumericOps(DataTypeOps):
|
|||
return column_op(rmod)(left, right)
|
||||
|
||||
def neg(self, operand: IndexOpsLike) -> IndexOpsLike:
|
||||
return cast(IndexOpsLike, column_op(Column.__neg__)(operand))
|
||||
return operand._with_new_scol(-operand.spark.column, field=operand._internal.data_fields[0])
|
||||
|
||||
def abs(self, operand: IndexOpsLike) -> IndexOpsLike:
|
||||
return cast(IndexOpsLike, column_op(F.abs)(operand))
|
||||
return operand._with_new_scol(
|
||||
F.abs(operand.spark.column), field=operand._internal.data_fields[0]
|
||||
)
|
||||
|
||||
def lt(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
|
||||
return column_op(Column.__lt__)(left, right)
|
||||
|
|
Loading…
Reference in a new issue