polars_lazy/physical_plan/streaming/
checks.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use polars_core::chunked_array::ops::SortMultipleOptions;
use polars_ops::prelude::*;
use polars_plan::plans::expr_ir::ExprIR;
use polars_plan::prelude::*;

pub(super) fn is_streamable_sort(
    slice: &Option<(i64, usize)>,
    sort_options: &SortMultipleOptions,
) -> bool {
    // check if slice is positive or maintain order is true
    if sort_options.maintain_order {
        false
    } else if let Some((offset, _)) = slice {
        *offset >= 0
    } else {
        true
    }
}

/// check if all expressions are a simple column projection
pub(super) fn all_column(exprs: &[ExprIR], expr_arena: &Arena<AExpr>) -> bool {
    exprs
        .iter()
        .all(|e| matches!(expr_arena.get(e.node()), AExpr::Column(_)))
}

pub(super) fn streamable_join(args: &JoinArgs) -> bool {
    let supported = match args.how {
        #[cfg(feature = "cross_join")]
        JoinType::Cross => true,
        JoinType::Left => true,
        JoinType::Inner => {
            // no-coalescing not yet supported in streaming
            matches!(
                args.coalesce,
                JoinCoalesce::JoinSpecific | JoinCoalesce::CoalesceColumns
            )
        },
        JoinType::Full { .. } => true,
        _ => false,
    };
    supported && !args.validation.needs_checks()
}