Return a new `DataFrame` with duplicated rows removed as per the specified expression list according to the provided sorting expressions grouped by the `DISTINCT ON` clause expressions. # Example ``` # use datafusion::prelude::*; # use datafusion::error::Result; # use datafusion_common::assert_batches_sorted_eq; # #[tokio::main] # async fn main() -> Result<()> { let ctx = SessionContext::new(); l
(
self,
on_expr: Vec<Expr>,
select_expr: Vec<Expr>,
sort_expr: Option<Vec<SortExpr>>,
)
| 962 | /// # } |
| 963 | /// ``` |
| 964 | pub fn distinct_on( |
| 965 | self, |
| 966 | on_expr: Vec<Expr>, |
| 967 | select_expr: Vec<Expr>, |
| 968 | sort_expr: Option<Vec<SortExpr>>, |
| 969 | ) -> Result<DataFrame> { |
| 970 | let plan = LogicalPlanBuilder::from(self.plan) |
| 971 | .distinct_on(on_expr, select_expr, sort_expr)? |
| 972 | .build()?; |
| 973 | Ok(DataFrame { |
| 974 | session_state: self.session_state, |
| 975 | plan, |
| 976 | projection_requires_validation: true, |
| 977 | }) |
| 978 | } |
| 979 | |
| 980 | /// Return a new `DataFrame` that has statistics for a DataFrame. |
| 981 | /// |