Port unwrap_cast tests to ExprSimplifier#7
Merged
jayzhan211 merged 4 commits intojayzhan211:mv-unwrap-cast-to-sim-exprfrom Mar 6, 2025
Merged
Port unwrap_cast tests to ExprSimplifier#7jayzhan211 merged 4 commits intojayzhan211:mv-unwrap-cast-to-sim-exprfrom
unwrap_cast tests to ExprSimplifier#7jayzhan211 merged 4 commits intojayzhan211:mv-unwrap-cast-to-sim-exprfrom
Conversation
alamb
commented
Mar 6, 2025
| schema: Arc::clone(schema), | ||
| }; | ||
| expr.rewrite(&mut expr_rewriter).data().unwrap() | ||
| let props = ExecutionProps::new(); |
Author
There was a problem hiding this comment.
The original tests looked like the following
fn optimize_test(expr: Expr, schema: &DFSchemaRef) -> Expr {
let mut expr_rewriter = UnwrapCastExprRewriter {
schema: Arc::clone(schema),
};
expr.rewrite(&mut expr_rewriter).data().unwrap()
}I changed optimize_test to use ExprSimplifier instead and most of the test just pass unchanged
| // cast(INT8(NULL), INT32) < INT32(12) => INT8(NULL) < INT8(12) => BOOL(NULL) | ||
| let lit_lt_lit = cast(null_i8(), DataType::Int32).lt(lit(12i32)); | ||
| let expected = null_i8().lt(lit(12i8)); | ||
| let expected = null_bool(); |
Author
There was a problem hiding this comment.
simplifier simplifies this expression to a constant
| // arrow_cast('value', 'Dictionary<Int32, Utf8>') = cast(str1 as Dictionary<Int32, Utf8>) => Utf8('value1') = str1 | ||
| let expr_input = lit(dict.clone()).eq(cast(col("str1"), dict.data_type())); | ||
| let expected = lit("value").eq(col("str1")); | ||
| let expected = col("str1").eq(lit("value")); |
Author
There was a problem hiding this comment.
expr simplifier puts the expressions in canonical order so this gets changed
| let expr_lt = | ||
| cast(col("c1"), DataType::Int64).in_list(vec![lit(12i64), lit(24i64)], false); | ||
| let expected = col("c1").in_list(vec![lit(12i32), lit(24i32)], false); | ||
| // INT32(C1) IN (INT32(12),INT64(23),INT64(34),INT64(56),INT64(78)) -> |
Author
There was a problem hiding this comment.
ExprSimplifier rewrites small IN lists to BooleanExpr so I had to increase the size of the lists in these tests to avoid that rewrite
df9f60c
into
jayzhan211:mv-unwrap-cast-to-sim-expr
24 of 25 checks passed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
UnwrapCastInComparisonintoSimplifierapache/datafusion#15012Rationale for this change
@berkaysynnada and I agree that removing these tests would likely result in a lack of coverage. See https://github.com/apache/datafusion/pull/15012/files#r1982223008
What changes are included in this PR?
ports the tests from unwrap_cast to live along side the code in the simplifier
I purposely kept the commits separate to make the review easier
Are these changes tested?
All tests, no code change
Are there any user-facing changes?