Posts

Spark Flattening Row using explode function

Example 1.  This a simple case of row flattening and generating cartesian product. Source +---+------+---------+-----------+ | id |itemid|quntity   |   price      | +---+------+---------+-----------+ |  A| 1,2,3 |    2,2,1  | 30,19,10  | |  B|   3,5  |      5,8   |    18,40    | +---+------+---------+------------+ Note : Source table contains columns with value as String delimited by " , "; Target +---+------+---------+---------+ | id|itemid|quntity    |  price   | +---+------+---------+---------+ |  A|     1|        2|       30| |  A|     1|        2|       19| |  A|     1|        2|       10| |  A|     1...