val temp = sqlContext.sql(s"SELECT A, B, C, (CASE WHEN (D) in (1,2,3) THEN ((E)+0.000)/60 ELSE 0 END) AS Z from TEST.TEST_TABLE")
val temp1 = temp.map({ temp => ((temp.getShort(0), temp.getString(1)), (USAGE_TEMP.getDouble(2), USAGE_TEMP.getDouble(3)))})
.reduceByKey((x, y) => ((x._1+y._1),(x._2+y._2)))
而不是上面的代码在hive层上进行计算(案例评估)我希望在scala中完成转换。我会怎么做?将hive sql查询转换为Spark
填写Map中的数据时可以做同样的事吗?
'withColumn'method是另一种方法除了'map'通过下面sarvesh提出的方法 –