My dataframe which was created by reading a RDBMS table, has one column and only one value in it:
val sourceCols = spark.read.format("jdbc").option("url", hiveMetaConURL)
.option("dbtable", "(select source_columns from base.spe_tab where tablename='base.forecast') as sCols")
.option("user", metaUserName)
.option("password", metaPassword)
.load()
I tried it convert it to a String in the below way:
val sourceColDataTypes = sourceCols.rdd.map(_.mkString(",")).collect.foreach(println)
When I try to print it as:
sourceColDataTypes.foreach(println)
I don't see the content, instead I see:
[Ljava.lang.String;@1e489957
Is there a way I can use yield of Scala to get the value. Could anyone let me know how can I convert a row in a DataFrame to a String ?
sourceCols.rdd.map(_.toSeq.mkString(",")).collect.foreach(println)