-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Convert concat during IR conversion (#16016)
- Loading branch information
Showing
8 changed files
with
93 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
crates/polars-plan/src/logical_plan/conversion/convert_utils.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use super::*; | ||
|
||
pub(super) fn convert_st_union( | ||
inputs: &mut [Node], | ||
lp_arena: &mut Arena<IR>, | ||
expr_arena: &mut Arena<AExpr>, | ||
) -> PolarsResult<()> { | ||
let mut schema = (**lp_arena.get(inputs[0]).schema(lp_arena)).clone(); | ||
|
||
let mut changed = false; | ||
for input in inputs[1..].iter() { | ||
let schema_other = lp_arena.get(*input).schema(lp_arena); | ||
changed |= schema.to_supertype(schema_other.as_ref())?; | ||
} | ||
|
||
if changed { | ||
for input in inputs { | ||
let mut exprs = vec![]; | ||
let input_schema = lp_arena.get(*input).schema(lp_arena); | ||
|
||
let to_cast = input_schema.iter().zip(schema.iter_dtypes()).flat_map( | ||
|((left_name, left_type), st)| { | ||
if left_type != st { | ||
Some(col(left_name.as_ref()).cast(st.clone())) | ||
} else { | ||
None | ||
} | ||
}, | ||
); | ||
exprs.extend(to_cast); | ||
|
||
if !exprs.is_empty() { | ||
let expr = to_expr_irs(exprs, expr_arena); | ||
let lp = IRBuilder::new(*input, expr_arena, lp_arena) | ||
.with_columns(expr, Default::default()) | ||
.build(); | ||
|
||
let node = lp_arena.add(lp); | ||
*input = node | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters