Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Rust test for logical plan optimizer for categoricals #9828

Closed
stinodego opened this issue Jul 12, 2023 · 1 comment · Fixed by #11135
Closed

Fix Rust test for logical plan optimizer for categoricals #9828

stinodego opened this issue Jul 12, 2023 · 1 comment · Fixed by #11135
Labels
accepted Ready for implementation rust Related to Rust Polars test Related to the test suite

Comments

@stinodego
Copy link
Member

stinodego commented Jul 12, 2023

There's a Rust test for the logical plan optimizer for categorical columns. It should do the following:

  • Make sure categorical columns are not cast to Utf8 when doing an equality check with a string literal.
  • Make sure categorical columns ARE cast to Utf8 when doing an addition with a string literal

See code here:

#[cfg(test)]
#[cfg(feature = "dtype-categorical")]
mod test {
use polars_core::prelude::*;
use super::*;
use crate::prelude::*;
#[test]
fn test_categorical_utf8() {
let mut rules: Vec<Box<dyn OptimizationRule>> = vec![Box::new(TypeCoercionRule {})];
let schema = Schema::from_iter([Field::new("fruits", DataType::Categorical(None))]);
let expr = col("fruits").eq(lit("somestr"));
let out = optimize_expr(expr.clone(), schema.clone(), &mut rules);
// we test that the fruits column is not casted to utf8 for the comparison
assert_eq!(out, expr);
let expr = col("fruits") + (lit("somestr"));
let out = optimize_expr(expr, schema, &mut rules);
let expected = col("fruits").cast(DataType::Utf8) + lit("somestr");
assert_eq!(out, expected);
}
}

However, the test does not compile. It is outdated and hasn't been run in a while. Still, we want to test this functionality. So the test should be rewritten for the latest syntax.

@stinodego stinodego added rust Related to Rust Polars test Related to the test suite labels Jul 12, 2023
@stinodego stinodego changed the title Fix Rust test for optimize_expr functionality Fix Rust test for logical plan optimizer for categoricals Jul 12, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in Backlog Jul 12, 2023
@stinodego stinodego moved this from Untriaged to Ready in Backlog Jul 12, 2023
@ritchie46
Copy link
Member

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation rust Related to Rust Polars test Related to the test suite
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants