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

Hao Ren updated SPARK-8527:
---------------------------
    Description: 
According to the following line of code below:

https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala#L209

The casting should be successful, however after type erasure, I encounter 
{{java.lang.ClassCastException}}:

{code}
ArrayList<StructField> structFields = new ArrayList<>();
// Some add operation
return StructType$.MODULE$.apply(structFields); // run time error

Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; 
cannot be cast to [Lorg.apache.spark.sql.types.StructField;
        at org.apache.spark.sql.types.StructType$.apply(StructType.scala:209)
{code}

Am I missing anything ?

  was:
According to the following line of code below:

https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala#L209

The casting should be successful, however after type erasure, I encounter 
{{java.lang.ClassCastException}}:

Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; 
cannot be cast to [Lorg.apache.spark.sql.types.StructField;
        at org.apache.spark.sql.types.StructType$.apply(StructType.scala:209)

Am I missing anything ?


> StructType's Factory method does not work in java code
> ------------------------------------------------------
>
>                 Key: SPARK-8527
>                 URL: https://issues.apache.org/jira/browse/SPARK-8527
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.4.0
>            Reporter: Hao Ren
>
> According to the following line of code below:
> https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala#L209
> The casting should be successful, however after type erasure, I encounter 
> {{java.lang.ClassCastException}}:
> {code}
> ArrayList<StructField> structFields = new ArrayList<>();
> // Some add operation
> return StructType$.MODULE$.apply(structFields); // run time error
> Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; 
> cannot be cast to [Lorg.apache.spark.sql.types.StructField;
>       at org.apache.spark.sql.types.StructType$.apply(StructType.scala:209)
> {code}
> Am I missing anything ?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to