[ 
https://issues.apache.org/jira/browse/SPARK-62310?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hyukjin Kwon updated SPARK-62310:
---------------------------------
    Description: 
On master f71ddd17 against PySpark 4.3.0, StructField.needConversion of the 
Python client takes 887 ns against 61 ns, so 2,000 StructType.add calls with 
metadata (PySpark's own quadratic algorithm, [f.needConversion() for f in self] 
at each add) take 1,583 ms against 127 ms, and StructType of 2,000 fields takes 
1.61 ms against 0.21 ms. The needConversion of a field reaches its type through 
the generic need_conversion_of_object -> is_udt + py_to_data_type path rather 
than the type's own method (51 ns). Make it as fast as PySpark's, keeping 
PySpark's semantics for subclasses, values that are not types and UDTs.


Master also differs from PySpark 4.3.0 in its semantics: (a) StructField, 
ArrayType and MapType.needConversion coerce the result that they delegate to a 
bool, where PySpark returns it raw (a subclass's 'yes' gives 'yes', and 
_needConversion holds the raw values); (b) a patched type class 
(IntegerType.needConversion = ...) is ignored by the field, array or map, where 
PySpark sees it; (c) a patched DataType.needConversion does not reach the 
atomic types, as each native atomic class defines its own method, where 
PySpark's inherit it from DataType. Dispatch needConversion as PySpark does, 
the atomic classes that inherit it in PySpark inheriting it here too.

  was:
On master f71ddd17 against PySpark 4.3.0, StructField.needConversion of the 
Python client takes 887 ns against 61 ns, so 2,000 StructType.add calls with 
metadata (PySpark's own quadratic algorithm, [f.needConversion() for f in self] 
at each add) take 1,583 ms against 127 ms, and StructType of 2,000 fields takes 
1.61 ms against 0.21 ms. The needConversion of a field reaches its type through 
the generic need_conversion_of_object -> is_udt + py_to_data_type path rather 
than the type's own method (51 ns). Make it as fast as PySpark's, keeping 
PySpark's semantics for subclasses, values that are not types and UDTs.


        Summary: Make needConversion of the drop-in's types dispatch as 
PySpark's, which makes StructField.needConversion, StructType.add and the 
StructType constructor as fast as PySpark's  (was: Make 
StructField.needConversion of the drop-in as fast as PySpark's, so that 
StructType.add and the StructType constructor are)

> Make needConversion of the drop-in's types dispatch as PySpark's, which makes 
> StructField.needConversion, StructType.add and the StructType constructor as 
> fast as PySpark's
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SPARK-62310
>                 URL: https://issues.apache.org/jira/browse/SPARK-62310
>             Project: Spark
>          Issue Type: Improvement
>          Components: Connect
>    Affects Versions: 5.0.0
>            Reporter: Hyukjin Kwon
>            Priority: Major
>
> On master f71ddd17 against PySpark 4.3.0, StructField.needConversion of the 
> Python client takes 887 ns against 61 ns, so 2,000 StructType.add calls with 
> metadata (PySpark's own quadratic algorithm, [f.needConversion() for f in 
> self] at each add) take 1,583 ms against 127 ms, and StructType of 2,000 
> fields takes 1.61 ms against 0.21 ms. The needConversion of a field reaches 
> its type through the generic need_conversion_of_object -> is_udt + 
> py_to_data_type path rather than the type's own method (51 ns). Make it as 
> fast as PySpark's, keeping PySpark's semantics for subclasses, values that 
> are not types and UDTs.
> Master also differs from PySpark 4.3.0 in its semantics: (a) StructField, 
> ArrayType and MapType.needConversion coerce the result that they delegate to 
> a bool, where PySpark returns it raw (a subclass's 'yes' gives 'yes', and 
> _needConversion holds the raw values); (b) a patched type class 
> (IntegerType.needConversion = ...) is ignored by the field, array or map, 
> where PySpark sees it; (c) a patched DataType.needConversion does not reach 
> the atomic types, as each native atomic class defines its own method, where 
> PySpark's inherit it from DataType. Dispatch needConversion as PySpark does, 
> the atomic classes that inherit it in PySpark inheriting it here too.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to