简体   繁体   中英

Coalesce columns in spark java dataframe

There are similar posts on Stack Overflow for the same question but none on a Java Spark Dataframe.

Can anyone help me with the same but in java.

I tried the solution posted here but its not working on Java. Seems like coalesce function takes Scala.collections.seq<columns> as type. how to make it work in Java

I had to convert the columns to Seq to make it work in Java 8.

public Seq<Column> getSeqString(Column a, Column b)
    {
        ArrayList<Column> cols = new ArrayList<Column>();
        cols.add(a);
        cols.add(b);
        return scala.collection.JavaConverters.collectionAsScalaIterableConverter(cols).asScala().toBuffer();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM