Thanks Nick, Sean and everyone. That did it
BTW I registered UDF for later use in a program
Anyway this is the much simplified code
import scala.util.Random
//
// UDF to create a random string of length characters
//
def randomString(chars: String, length: Int): String =
(0 until length).map(
That’s because of this:
scala> val text =
Array((1,"hNjLJEgjxn"),(2,"lgryHkVlCN"),(3,"ukswqcanVC"),(4,"ZFULVxzAsv"),(5,"LNzOozHZPF"),(6,"KZPYXTqMkY"),(7,"DVjpOvVJTw"),(8,"LKRYrrLrLh"),(9,"acheneIPDM"),(10,"iGZTrKfXNr"))
text: Array[(Int, String)] = Array((1,hNjLJEgjxn), (2,lgryHkVlCN),
(3,ukswqc
> How about something like
>
> scala> val text = (1 to 10).map(i => (i.toString,
> random_string(chars.mkString(""), 10))).toArray
>
> text: Array[(String, String)] = Array((1,FBECDoOoAC), (2,wvAyZsMZnt),
> (3,KgnwObOFEG), (4,tAZPRodrgP), (5,uSgrqyZGuc), (6,ztrTmbkOhO),
> (7,qUbQsKtZWq), (8,JDokbiF
Hi gents,
Well I was trying to see whether I can create an array of elements. From
RDD to DF, register as TempTable and store it as a Hive table
import scala.util.Random
//
// UDF to create a random string of charlength characters
//
def random_string(chars: String, charlength: Int) : String = {
what is "text"? i.e. what is the "val text = ..." definition?
If text is a String itself then indeed sc.parallelize(Array(text)) is doing
the correct thing in this case.
On Tue, 23 Aug 2016 at 19:42 Mich Talebzadeh
wrote:
> I am sure someone know this :)
>
> Created a dynamic text string which
I am sure someone know this :)
Created a dynamic text string which has format
scala> println(text)
(1,"hNjLJEgjxn"),(2,"lgryHkVlCN"),(3,"ukswqcanVC"),(4,"ZFULVxzAsv"),(5,"LNzOozHZPF"),(6,"KZPYXTqMkY"),(7,"DVjpOvVJTw"),(8,"LKRYrrLrLh"),(9,"acheneIPDM"),(10,"iGZTrKfXNr")
now if I do
scala> val df