How to call DataFrameFunctions.createCassandraTabl

2019-09-17 22:22发布

问题:

How can I call this function from Java? Or do I need a wrapper in scala?

package com.datastax.spark.connector

class DataFrameFunctions(dataFrame: DataFrame) extends Serializable {
...    
  def createCassandraTable(
    keyspaceName: String,
    tableName: String,
    partitionKeyColumns: Option[Seq[String]] = None,
    clusteringKeyColumns: Option[Seq[String]] = None)(
  implicit
    connector: CassandraConnector = CassandraConnector(sparkContext.getConf)): Unit = {
...

回答1:

I used the following code :

DataFrameFunctions frameFunctions = new DataFrameFunctions(dfTemp2);
Seq<String> argumentsSeq1 = JavaConversions.asScalaBuffer(Arrays.asList("CategoryName")).seq();     
Option<Seq<String>> some1 = new Some<Seq<String>>(argumentsSeq1);       
Seq<String> argumentsSeq2 = JavaConversions.asScalaBuffer(Arrays.asList("DealType")).seq();         
Option<Seq<String>> some2 = new Some<Seq<String>>(argumentsSeq2);                                                               
frameFunctions.createCassandraTable("coupons", "IdealFeeds", some1, some2, connector);