You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/09/11 00:46:49 UTC
[GitHub] [arrow-datafusion] liukun4515 commented on a diff in pull request #3422: support cast/try_cast in prune with signed integer and decimal
liukun4515 commented on code in PR #3422:
URL: https://github.com/apache/arrow-datafusion/pull/3422#discussion_r967720763
##########
datafusion/core/src/physical_optimizer/pruning.rs:
##########
@@ -1995,4 +2039,66 @@ mod tests {
let result = p.prune(&statistics).unwrap();
assert_eq!(result, expected_ret);
}
+
+ #[test]
+ fn test_rewrite_expr_to_prunable() {
+ let schema = Schema::new(vec![Field::new("a", DataType::Int32, true)]);
+ let df_schema = DFSchema::try_from(schema).unwrap();
+ // column op lit
+ let left_input = col("a");
+ let right_input = lit(ScalarValue::Int32(Some(12)));
+ let (result_left, _, result_right) = rewrite_expr_to_prunable(
+ &left_input,
+ Operator::Eq,
+ &right_input,
+ df_schema.clone(),
+ )
+ .unwrap();
+ assert_eq!(result_left, left_input);
+ assert_eq!(result_right, right_input);
+ // cast op lit
+ let left_input = cast(col("a"), DataType::Decimal128(20, 3));
+ let right_input = lit(ScalarValue::Decimal128(Some(12), 20, 3));
+ let (result_left, _, result_right) = rewrite_expr_to_prunable(
+ &left_input,
+ Operator::Gt,
+ &right_input,
+ df_schema.clone(),
+ )
+ .unwrap();
+ assert_eq!(result_left, left_input);
+ assert_eq!(result_right, right_input);
+ // try_cast op lit
+ let left_input = try_cast(col("a"), DataType::Int64);
+ let right_input = lit(ScalarValue::Int64(Some(12)));
+ let (result_left, _, result_right) =
+ rewrite_expr_to_prunable(&left_input, Operator::Gt, &right_input, df_schema)
+ .unwrap();
+ assert_eq!(result_left, left_input);
+ assert_eq!(result_right, right_input);
+ // TODO: add test for other case and op
Review Comment:
I find i have added the test for executing with real data in the `prune_cast_column_scalar` function.
You can check them, it just include cast(col, int64) and try_cast(col,int64). If you think it is not enough, you can add more test for it or give some advices for the test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org