Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- orderedDataFrame.foreach(new Function1<Row,BoxedUnit>(){
- @Override
- public BoxedUnit apply(Row v1) {
- //how to I change Row here
- //I want to change column no 2 using v1.get(2)
- //also what is BoxedUnit how do I use it
- return null;
- }
- });
- final DataFrame withoutCurrency = sqlContext.createDataFrame(somedf.javaRDD().map(row -> {
- return RowFactory.create(row.get(0), row.get(1), someMethod(row.get(2)));
- }), somedf.schema());
- Dataset<Row> ds = spark.createDataFrame(Collections.singletonList(data), SellerAsinAttribute.class);
- ds.map((i)-> {
- Object arrayObj = Array.newInstance(Object.class, i.length());
- for (int n = 0; n < i.length(); ++n) {
- Array.set(arrayObj, n, i.get(n));//change 'i.get(n)' to anything you want, if you change type, remember to update schema
- }
- Method create = RowFactory.class.getMethod("create", Object[].class);
- return (Row) create.invoke(null, arrayObj);
- }, RowEncoder.apply(ds.schema())).show();
Add Comment
Please, Sign In to add comment