Gets the first record in the RelationalGroupeddataset.
The first API has several implementations, as follows. The exact API used depends on the specific use case:
def first(columnName: String): Column
Aggregate function: returns the first value of a column in a group.
def first(e: Column): Column
Aggregate function: returns the first value in a group.
def first(columnName: String, ignoreNulls: Boolean): Column
Aggregate function: returns the first value of a column in a group.
def first(e: Column, ignoreNulls: Boolean): Column
Aggregate function: returns the first value in a group.
Let's look at an example of invoking first on the DataFrame to output the first row:
import org.apache.spark.sql.functions._
scala> statesPopulationDF.select(first("State")).show
+-------------------+
|first(State, false)|
+-------------------+
| Alabama|
+-------------------+