erratic-pattern opened a new issue, #10359:
URL: https://github.com/apache/datafusion/issues/10359
### Describe the bug
The `LogFunc::simplify` function swaps the order of arguments.
### To Reproduce
I have created a test case that can reproduce the issue:
```rust
#[test]
// Test that non-simplifiable log() expressions are unchanged after
simplification
fn test_log_simplify_original() {
let props = ExecutionProps::new();
let schema = Arc::new(DFSchema::new_with_metadata(vec![],
HashMap::new()).unwrap());
let context = SimplifyContext::new(&props).with_schema(schema);
// One argument with no simplifications
let result = LogFunc::new()
.simplify(vec![lit(2)], &context)
.unwrap();
match result {
ExprSimplifyResult::Simplified(_) => panic!("Expected
ExprSimplifyResult::Original"),
ExprSimplifyResult::Original(args) => {
assert_eq!(args.len(), 1);
assert_eq!(args[0], lit(2));
}
}
// Two arguments with no simplifications
let result = LogFunc::new()
.simplify(vec![lit(2), lit(3)], &context)
.unwrap();
match result {
ExprSimplifyResult::Simplified(_) => panic!("Expected
ExprSimplifyResult::Original"),
ExprSimplifyResult::Original(args) => {
assert_eq!(args.len(), 2);
assert_eq!(args[0], lit(2));
assert_eq!(args[1], lit(3));
}
}
}
```
test results:
```
---- math::log::tests::test_log_simplify_original stdout ----
thread 'math::log::tests::test_log_simplify_original' panicked at
datafusion/functions/src/math/log.rs:330:17:
assertion `left == right` failed
left: Literal(Int32(3))
right: Literal(Int32(2))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
### Expected behavior
Arguments should remain in correct order of `log(base, number)`
### Additional context
This bug seems to be hiddenby the fact that the expression simplifier runs
twice. In most cases this means the arguments will swap back into place, but it
may be possible to craft expressions which only run simplify once.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]