Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-50051][PYTHON][CONNECT] Make
lit
works with empty numpy ndarray
### What changes were proposed in this pull request? Make `lit` works with empty numpy ndarray ### Why are the changes needed? bug fix, the schema for empty ndarray is incorrect PySpark Classic: ``` In [3]: spark.range(1).select(sf.lit(np.array([1,2,3], np.int32))).schema Out[3]: StructType([StructField('ARRAY(1, 2, 3)', ArrayType(IntegerType(), True), False)]) In [4]: spark.range(1).select(sf.lit(np.array([], np.int32))).schema Out[4]: StructType([StructField('ARRAY()', ArrayType(IntegerType(), True), False)]) ``` ### Does this PR introduce _any_ user-facing change? before: ``` In [7]: spark.range(1).select(sf.lit(np.array([], np.int32))).schema Out[7]: StructType([StructField('array()', ArrayType(NullType(), False), False)]) ``` after: ``` In [3]: spark.range(1).select(sf.lit(np.array([], np.int32))).schema Out[3]: StructType([StructField('array()', ArrayType(IntegerType(), True), False)]) ``` ### How was this patch tested? added tests ### Was this patch authored or co-authored using generative AI tooling? no Closes #48589 from zhengruifeng/connect_empty_ndarray. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Ruifeng Zheng <ruifengz@apache.org>
- Loading branch information