Github user MLnick commented on the issue:

    https://github.com/apache/spark/pull/12790
  
    Actually the behavior in Scala is consistent - passing in `Array()` or 
`Array.empty()` you are passing in `Array[Nothing]` so that is why there is a 
`ClassCastException`.
    
    Passing in an empty array of the correct type works as an identity 
transformer, as documented:
    
    ```
    scala> df.show
    +---+----+
    | id|text|
    +---+----+
    |  1| foo|
    |  2| bar|
    |  3| baz|
    +---+----+
    
    scala> val p = new Pipeline()
    p: org.apache.spark.ml.Pipeline = pipeline_0778ab6ded4f
    
    scala> p.setStages(Array[PipelineStage]())
    res20: p.type = pipeline_0778ab6ded4f
    
    scala> p.fit(df).transform(df).show
    +---+----+
    | id|text|
    +---+----+
    |  1| foo|
    |  2| bar|
    |  3| baz|
    +---+----+
    ```
    
    Personally, I find it weird to allow empty stages - what use is an identity 
transformer? I'd prefer to throw an error during `setStages` if it's empty. But 
perhaps not worth changing ...
    
    If we don't make that change, we could make it on the Scala side that if an 
array is passed that is empty, set stages to a new `Array[PipelineStage]`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to