import org.apache.spark.sql.functions._
val df1 = Seq(
("A",1,5,3),
("B",3,4,2),
("C",4,6,3),
("D",5,9,1)).toDF("a","b","c","d")
df1.createOrReplaceTempView("table")
df1.show()
val df2 = spark.sql("select ' ' as col1, b as b1, c+d as e from table ").show()
2条答案
按热度按时间flvtvl501#
使用sparksql,您也可以这样做。
输入:
输出:
iq3niunx2#
也可以使用本机df函数。例如:
选择以下列:
提供预期结果: