devanbenz opened a new pull request, #12000:
URL: https://github.com/apache/datafusion/pull/12000

   Signed-off-by: Devan <[email protected]>## Which issue does this PR close?
   
   Closes #11982 
   
   ## Rationale for this change
   
   Previous usage of dataframe `with_column` using a Window expression was 
causing an unnecessary projection in the output. 
   
   ```
   
+---+-----------------------------------------------------------------------+---+
   | a | ROW_NUMBER() ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING 
| r |
   
+---+-----------------------------------------------------------------------+---+
   | 1 | 1                                                                     
| 1 |
   | 2 | 2                                                                     
| 2 |
   | 3 | 3                                                                     
| 3 |
   | 4 | 4                                                                     
| 4 |
   | 5 | 5                                                                     
| 5 |
   
+---+-----------------------------------------------------------------------+---+
   ```
   
   `ROW_NUMBER() ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` 
shows up in the Logical plan schema as a Field. This change ultimately filters 
out a field if it has no qualifier which appears to fix the issue since there 
is no qualifier for this Field. 
   
   I also tested manually with a few other `Expr` to test if that would cause 
issues by filtering the qualifier:
   
   ```
       let func = Expr::Literal(ScalarValue::Int32(Some(10)));
       df.with_column("r", func)?.show().await?;
   ```
   outputs:
   
   ```
   +---+----+
   | a | r  |
   +---+----+
   | 5 | 10 |
   | 4 | 10 |
   | 3 | 10 |
   | 2 | 10 |
   | 1 | 10 |
   +---+----+
   ``` 
   
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   


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

Reply via email to