MCPcopy Create free account
hub / github.com/apache/datafusion / distinct_on

Method distinct_on

datafusion/core/src/dataframe/mod.rs:964–978  ·  view source on GitHub ↗

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>>,
    )

Source from the content-addressed store, hash-verified

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 ///

Callers 5

select_to_planMethod · 0.45
try_into_logical_planMethod · 0.45
test_distinct_onFunction · 0.45
test_distinct_on_sort_byFunction · 0.45

Calls 1

buildMethod · 0.45

Tested by 3

test_distinct_onFunction · 0.36
test_distinct_on_sort_byFunction · 0.36