Advertisement

Spark获取DataFrame中列的方式:col;$;column;apply

阅读量:

使用需要导包:

复制代码
       import spark.implicits._
       import org.apache.spark.sql.functions._
       import org.apache.spark.sql.Column

官方说明:

复制代码
       df("columnName")            // On a specific DataFrame.
       col("columnName")           // A generic column no yet associated with a DataFrame.
       col("columnName.field")     // Extracting a struct field
       col("`a.column.with.dots`") // Escape `.` in column names.
       $"columnName"               // Scala short hand for a named column.
       expr("a + 1")               // A column that is constructed from a parsed SQL Expre

全部评论 (0)

还没有任何评论哟~