Skip to content

Commit

Permalink
docs: polars-lazy readability improvements (#3701)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrussell committed Jun 15, 2022
1 parent 97e24e0 commit 26e142a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl OptimizationRule for AggregatePushdown {
input,
schema,
} => self.pushdown_projection(node, expr, input, schema, lp_arena, expr_arena),
// todo! hstack should pushown not dependent columns
// todo! hstack should pushdown not dependent columns
Join { .. } | Aggregate { .. } | HStack { .. } | DataFrameScan { .. } => {
if self.accumulated_projections.is_empty() {
lp_arena.replace(node, lp);
Expand Down
10 changes: 5 additions & 5 deletions polars/polars-lazy/src/logical_plan/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::*;
use crate::utils::has_nth;
use polars_arrow::index::IndexToUsize;

/// This replace the wilcard Expr with a Column Expr. It also removes the Exclude Expr from the
/// This replace the wildcard Expr with a Column Expr. It also removes the Exclude Expr from the
/// expression chain.
pub(super) fn replace_wildcard_with_column(mut expr: Expr, column_name: Arc<str>) -> Expr {
expr.mutate().apply(|e| {
Expand Down Expand Up @@ -51,9 +51,9 @@ fn rewrite_special_aliases(expr: Expr) -> Expr {
/// Take an expression with a root: col("*") and copies that expression for all columns in the schema,
/// with the exclusion of the `names` in the exclude expression.
/// The resulting expressions are written to result.
fn replace_wilcard(expr: &Expr, result: &mut Vec<Expr>, exclude: &[Arc<str>], schema: &Schema) {
fn replace_wildcard(expr: &Expr, result: &mut Vec<Expr>, exclude: &[Arc<str>], schema: &Schema) {
for name in schema.iter_names() {
if !exclude.iter().any(|exluded| &**exluded == name) {
if !exclude.iter().any(|excluded| &**excluded == name) {
let new_expr = replace_wildcard_with_column(expr.clone(), Arc::from(name.as_str()));
let new_expr = rewrite_special_aliases(new_expr);
result.push(new_expr)
Expand Down Expand Up @@ -306,7 +306,7 @@ fn function_wildcard_expansion(mut expr: Expr, schema: &Schema, exclude: &[Arc<s
}
_ => {
if has_wildcard(e) {
replace_wilcard(e, &mut new_inputs, exclude, schema)
replace_wildcard(e, &mut new_inputs, exclude, schema)
} else {
#[cfg(feature = "regex")]
{
Expand Down Expand Up @@ -371,7 +371,7 @@ pub(crate) fn rewrite_projections(exprs: Vec<Expr>, schema: &Schema, keys: &[Exp
result.push(expr);
continue;
}
replace_wilcard(&expr, &mut result, &exclude, schema);
replace_wildcard(&expr, &mut result, &exclude, schema);
} else {
#[allow(clippy::collapsible_else_if)]
#[cfg(feature = "regex")]
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-lazy/src/physical_plan/executors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn execute_projection_cached_window_fns(
// the partitioning messes with column order, so we also store the idx
// and use those to restore the original projection order
#[allow(clippy::type_complexity)]
// String: partion_name,
// String: partition_name,
// u32: index,
// bool: flatten (we must run those first because they need a sorted group tuples.
// if we cache the group tuples we must ensure we cast the sorted onces.
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-lazy/src/physical_plan/expressions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl<'a> AggregationContext<'a> {

/// In a binary expression one state can be aggregated and the other not.
/// If both would be flattened naively one would be sorted and the other not.
/// Calling this function will ensure both are sortened. This will be a no-op
/// Calling this function will ensure both are sorted. This will be a no-op
/// if already aggregated.
pub(crate) fn sort_by_groups(&mut self) {
// make sure that the groups are updated before we use them to sort.
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-lazy/src/tests/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ fn test_regex_selection() -> Result<()> {

#[test]
fn test_filter_in_groupby_agg() -> Result<()> {
// This tests if the fitler is correctly handled by the binary expression.
// This tests if the filter is correctly handled by the binary expression.
// This could lead to UB if it were not the case. The filter creates an empty column.
// but the group tuples could still be untouched leading to out of bounds aggregation.
let df = df![
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-lazy/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub(crate) fn rename_aexpr_root_names(node: Node, arena: &mut Arena<AExpr>, new_
}

/// Rename the root of the expression from `current` to `new` and assign to new node in arena.
/// Returns `Node` on first sucessful rename.
/// Returns `Node` on first successful rename.
pub(crate) fn aexpr_assign_renamed_root(
node: Node,
arena: &mut Arena<AExpr>,
Expand Down

0 comments on commit 26e142a

Please sign in to comment.