Guest User

Untitled

a guest
Nov 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // Row level transformations using map
  2.  
  3. val orders = sc.textFile("/public/retail_db/orders")
  4. // 21,2013-07-25 00:00:00.0,11599,CLOSED -> 20130725 as Int
  5. val str = orders.first
  6. str.split(",")(1).substring(0, 10).replace("-", "").toInt
  7.  
  8. val orderDates = orders.map((str: String) => {
  9. str.split(",")(1).substring(0, 10).replace("-", "").toInt
  10. })
  11.  
  12. val ordersPairedRDD = orders.map(order => {
  13. val o = order.split(",")
  14. (o(0).toInt, o(1).substring(0, 10).replace("-", "").toInt)
  15. })
  16.  
  17. val orderItems = sc.textFile("/public/retail_db/order_items")
  18. val orderItemsPairedRDD = orderItems.map(orderItem => {
  19. (orderItem.split(",")(1).toInt, orderItem)
  20. })
Add Comment
Please, Sign In to add comment