HaoYang670 opened a new issue, #3900:
URL: https://github.com/apache/arrow-datafusion/issues/3900

   **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:
   ```rust
   /// 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:
   ```sql
   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:
   ```rust
       #[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.
   


-- 
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]

Reply via email to