-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
help wantedExtra attention is neededExtra attention is needed
Description
Describe the bug
A clear and concise description of what the bug is.
Related to this function: https://github.com/apache/arrow-datafusion/blob/master/datafusion/expr/src/expr.rs#L951
To Reproduce
I add println here to check if the function is called:
/// Returns a readable name of an expression based on the input schema.
/// This function recursively transverses the expression for names such as "CAST(a > 2)".
fn create_name(e: &Expr) -> Result<String> {
println!("create name for e");note that the println command doesn't get the name of e to avoid recursive function calls.
Then I ran a really simple query in the datafusion-cli, and got the following result:
DataFusion CLI v13.0.0
❯ select 1;
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
create name for e
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
1 row in set. Query took 0.004 seconds.It is a little weird to me that the function create_name is called 18 times.
I also tested by constructing the expression directly:
#[test]
fn my_fail_test() {
let expr = lit(1);
// make the test failed, so that we can see the content from `println`
assert_eq!("UINT(2)", expr.display_name().unwrap())
}, and this works fine:
running 1 test
create name for e
thread 'expr::test::my_fail_test' panicked at 'assertion failed: `(left == right)`
left: `"UINT(2)"`,
right: `"Int32(1)"`', datafusion/expr/src/expr.rs:1255:9
Expected behavior
I guess the function create_name should only be called once for each expression.
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed