Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/5146#discussion_r27004837
--- Diff:
sql/core/src/test/java/test/org/apache/spark/sql/JavaDataFrameSuite.java ---
@@ -90,4 +98,27 @@ public void testShow() {
df.show();
df.show(1000);
}
+
+ public static class Bean implements Serializable {
+ private double a = 0.0;
+ private Integer[] b = new Integer[]{0, 1};
+
+ public double getA() {
+ return a;
+ }
+
+ public Integer[] getB() {
+ return b;
+ }
+ }
+
+ @Test
+ public void testCreateDataFrameFromJavaBeans() {
+ Bean bean = new Bean();
+ JavaRDD<Bean> rdd = jsc.parallelize(Arrays.asList(bean));
+ DataFrame df = context.createDataFrame(rdd, Bean.class);
+ Row first = df.select("a", "b").first();
+ Assert.assertEquals(bean.getA(), first.getDouble(0), 0.0);
+ Assert.assertArrayEquals(bean.getB(), first.<Integer[]>getAs(1));
--- End diff --
Would be better to add assertions for schema field data types.
---
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]