Professional Documents
Culture Documents
Ramsitsolution Scala Cotinue Part-2
Ramsitsolution Scala Cotinue Part-2
Transformation requires
Output::
Task:
Below data b/w words many spaces are there now I need to do like only
one space b/w each words
If you give directly it will concat all elements and as a string without
space
If you need space b/w words mkString(“space”)
These type of transformations require when u doing unstructured data
like from twitter, Facebook. bec they may be not following any
structure
Problem with tuple is we can’t remember the positions of elements
each elements. We can make data into structure but Tuple not having
schema
Similar to sql tables we need to provide schema.it is possible by case
classes.
Accessing elements is easy
Now I want to access element a(column) in s1 obj
Here each element in list is samp object. Now I want to add all
elements in each objectwise
Now we will try to coverts of emp records into case class
Functions
Zero arg or no-org function
Previously we manually did transformations by using and all. I f you
need these things regularly. Then we can create function and then we
can use these as reusability when ever required.
Create function for namefirst letter upper case and then remaining
are in lower case
Upper case function
Gender function
Recursive functions
For factorial
Because it is out of range int
Pwer function
X is declare as Int but you applying string so type mismatch
Above valid only if string contains pure numerics
Then wt is diff b/w & and &&
Dno=11
Active evaluation
Active: in the below expression second one is false but it is still checking
all conditions