1、选中代码
val userVisitActionDF = spark.sql("select * from " + Constants.TABLE_USER_VISIT_ACTION +
" where date >= ' " + startDate + " and date <=" + endDate +"'").as[UserVisitAction]
val userVisitActionRDD = userVisitActionDF.rdd
2、Refactor -> Extract -> Method
3、Extract method to object SessionAnalysis
4、Extract Method -> Name
5、ok
val userVisitActionRDD: RDD[UserVisitAction] = getUserVisitActionRDD(startDate, endDate, spark)
private def getUserVisitActionRDD(startDate: String, endDate: String, spark: SparkSession) = {
val userVisitActionDF = spark.sql("select * from " + Constants.TABLE_USER_VISIT_ACTION +
" where date >= ' " + startDate + " and date <=" + endDate + "'").as[UserVisitAction]
val userVisitActionRDD = userVisitActionDF.rdd
userVisitActionRDD
}