Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. val conf = new SparkConf().setAppName("MyApp").setMaster("local")
  2. val sc = new SparkContext(conf)
  3. val sqlcontext = new org.apache.spark.sql.SQLContext(sc)
  4. sqlcontext.setConf("url", "mysql://localhost:3306/myDB?user=us&password=pw")
  5.  
  6. val action = sqlcontext.jdbc(jdbcUrl, "action").registerTempTable("action")
  7. val session = sqlcontext.jdbc(jdbcUrl, "session").registerTempTable("session")
  8. sqlcontext.cacheTable("action")
  9. sqlcontext.cacheTable("session")
  10.  
  11. val data = sqlcontext.sql('SELECT * FROM action INNER JOIN session ON action.session_id = session.session_id")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement