polars_lazy/physical_plan/streaming/
checks.rs

1use polars_core::chunked_array::ops::SortMultipleOptions;
2use polars_ops::prelude::*;
3use polars_plan::plans::expr_ir::ExprIR;
4use polars_plan::prelude::*;
5
6pub(super) fn is_streamable_sort(
7    slice: &Option<(i64, usize)>,
8    sort_options: &SortMultipleOptions,
9) -> bool {
10    // check if slice is positive or maintain order is true
11    if sort_options.maintain_order {
12        false
13    } else if let Some((offset, _)) = slice {
14        *offset >= 0
15    } else {
16        true
17    }
18}
19
20/// check if all expressions are a simple column projection
21pub(super) fn all_column(exprs: &[ExprIR], expr_arena: &Arena<AExpr>) -> bool {
22    exprs
23        .iter()
24        .all(|e| matches!(expr_arena.get(e.node()), AExpr::Column(_)))
25}
26
27pub(super) fn streamable_join(args: &JoinArgs) -> bool {
28    let supported = match args.how {
29        #[cfg(feature = "cross_join")]
30        JoinType::Cross => true,
31        JoinType::Left => true,
32        JoinType::Inner => {
33            // no-coalescing not yet supported in streaming
34            matches!(
35                args.coalesce,
36                JoinCoalesce::JoinSpecific | JoinCoalesce::CoalesceColumns
37            )
38        },
39        JoinType::Full => true,
40        _ => false,
41    };
42    supported && !args.validation.needs_checks()
43}