Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Creates a DataFrame based on a table named "people"
- // stored in a MySQL database.
- String url =
- "jdbc:mysql://yourIP:yourPort/test?user=yourUsername;password=yourPassword";
- DataFrame df = sqlContext
- .read()
- .format("jdbc")
- .option("url", url)
- .option("dbtable", "people")
- .load();
- // Looks the schema of this DataFrame.
- df.printSchema();
- // Counts people by age
- DataFrame countsByAge = df.groupBy("age").count();
- countsByAge.show();
- // Saves countsByAge to S3 in the JSON format.
- countsByAge.write().format("json").save("s3a://...");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement