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

Method select

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

Project arbitrary expressions (like SQL SELECT expressions) into a new `DataFrame`. The output `DataFrame` has one column for each element in `expr_list`. # 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(); let df = ctx .read_csv("tests/d

(
        self,
        expr_list: impl IntoIterator<Item = impl Into<SelectExpr>>,
    )

Source from the content-addressed store, hash-verified

409 /// # }
410 /// ```
411 pub fn select(
412 self,
413 expr_list: impl IntoIterator<Item = impl Into<SelectExpr>>,
414 ) -> Result<DataFrame> {
415 let expr_list: Vec<SelectExpr> =
416 expr_list.into_iter().map(|e| e.into()).collect::<Vec<_>>();
417
418 let expressions = expr_list.iter().filter_map(|e| match e {
419 SelectExpr::Expression(expr) => Some(expr),
420 _ => None,
421 });
422
423 let window_func_exprs = find_window_exprs(expressions);
424 let plan = if window_func_exprs.is_empty() {
425 self.plan
426 } else {
427 LogicalPlanBuilder::window_plan(self.plan, window_func_exprs)?
428 };
429
430 let project_plan = LogicalPlanBuilder::from(plan).project(expr_list)?.build()?;
431
432 Ok(DataFrame {
433 session_state: self.session_state,
434 plan: project_plan,
435 projection_requires_validation: false,
436 })
437 }
438
439 /// Returns a new DataFrame containing all columns except the specified columns.
440 ///

Callers 15

planner_apiFunction · 0.45
query_parquet_demoFunction · 0.45
where_scalar_subqueryFunction · 0.45
where_in_subqueryFunction · 0.45
where_exist_subqueryFunction · 0.45
simple_udfFunction · 0.45
advanced_udfFunction · 0.45
roundtrip_expr_apiFunction · 0.45
criterion_benchmarkFunction · 0.45
select_columnsMethod · 0.45
select_exprsMethod · 0.45
drop_columnsMethod · 0.45

Calls 8

find_window_exprsFunction · 0.85
mapMethod · 0.45
into_iterMethod · 0.45
intoMethod · 0.45
iterMethod · 0.45
is_emptyMethod · 0.45
buildMethod · 0.45
projectMethod · 0.45

Tested by 15

roundtrip_expr_apiFunction · 0.36
select_exprFunction · 0.36
select_allFunction · 0.36
select_exprsFunction · 0.36
select_with_window_exprsFunction · 0.36
test_aggregate_with_pkFunction · 0.36
test_aggregate_with_pk3Function · 0.36
test_aggregate_with_pk4Function · 0.36
test_aggregate_aliasFunction · 0.36
test_aggregate_subexprFunction · 0.36