spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Chase (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (SPARK-6570) Spark SQL arrays: "explode()" fails and cannot save array type to Parquet
Date Fri, 27 Mar 2015 13:16:52 GMT

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

Jon Chase updated SPARK-6570:
-----------------------------
    Summary: Spark SQL arrays: "explode()" fails and cannot save array type to Parquet  (was:
Spark SQL "explode()" fails, assumes underlying SQL array is represented by Scala Seq)

> Spark SQL arrays: "explode()" fails and cannot save array type to Parquet
> -------------------------------------------------------------------------
>
>                 Key: SPARK-6570
>                 URL: https://issues.apache.org/jira/browse/SPARK-6570
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.3.0
>            Reporter: Jon Chase
>
> {code}
>     @Rule
>     public TemporaryFolder tmp = new TemporaryFolder();
>     @Test
>     public void testPercentileWithExplode() throws Exception {
>         StructType schema = DataTypes.createStructType(Lists.newArrayList(
>                 DataTypes.createStructField("col1", DataTypes.StringType, false),
>                 DataTypes.createStructField("col2s", DataTypes.createArrayType(DataTypes.IntegerType,
true), true)
>         ));
>         JavaRDD<Row> rowRDD = sc.parallelize(Lists.newArrayList(
>                 RowFactory.create("test", new int[]{1, 2, 3})
>         ));
>         DataFrame df = sql.createDataFrame(rowRDD, schema);
>         df.registerTempTable("df");
>         df.printSchema();
>         List<int[]> ints = sql.sql("select col2s from df").javaRDD()
>                               .map(row -> (int[]) row.get(0)).collect();
>         assertEquals(1, ints.size());
>         assertArrayEquals(new int[]{1, 2, 3}, ints.get(0));
>         // fails: lateral view explode does not work: java.lang.ClassCastException: [I
cannot be cast to scala.collection.Seq
>         List<Integer> explodedInts = sql.sql("select col2 from df lateral view
explode(col2s) splode as col2").javaRDD()
>                                         .map(row -> row.getInt(0)).collect();
>         assertEquals(3, explodedInts.size());
>         assertEquals(Lists.newArrayList(1, 2, 3), explodedInts);
>         // fails: java.lang.ClassCastException: [I cannot be cast to scala.collection.Seq
>         df.saveAsParquetFile(tmp.getRoot().getAbsolutePath() + "/parquet");
>         DataFrame loadedDf = sql.load(tmp.getRoot().getAbsolutePath() + "/parquet");
>         loadedDf.registerTempTable("loadedDf");
>         List<int[]> moreInts = sql.sql("select col2s from loadedDf").javaRDD()
>                                   .map(row -> (int[]) row.get(0)).collect();
>         assertEquals(1, moreInts.size());
>         assertArrayEquals(new int[]{1, 2, 3}, moreInts.get(0));
>     }
> {code}
> {code}
> root
>  |-- col1: string (nullable = false)
>  |-- col2s: array (nullable = true)
>  |    |-- element: integer (containsNull = true)
> ERROR org.apache.spark.executor.Executor Exception in task 7.0 in stage 1.0 (TID 15)
> java.lang.ClassCastException: [I cannot be cast to scala.collection.Seq
> 	at org.apache.spark.sql.catalyst.expressions.Explode.eval(generators.scala:125) ~[spark-catalyst_2.10-1.3.0.jar:1.3.0]
> 	at org.apache.spark.sql.execution.Generate$$anonfun$2$$anonfun$apply$1.apply(Generate.scala:70)
~[spark-sql_2.10-1.3.0.jar:1.3.0]
> 	at org.apache.spark.sql.execution.Generate$$anonfun$2$$anonfun$apply$1.apply(Generate.scala:69)
~[spark-sql_2.10-1.3.0.jar:1.3.0]
> 	at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371) ~[scala-library-2.10.4.jar:na]
> 	at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) ~[scala-library-2.10.4.jar:na]
> 	at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) ~[scala-library-2.10.4.jar:na]
> 	at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) ~[scala-library-2.10.4.jar:na]
> 	at scala.collection.Iterator$class.foreach(Iterator.scala:727) ~[scala-library-2.10.4.jar:na]
> 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1157) ~[scala-library-2.10.4.jar:na]
> {code}



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

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


Mime
View raw message