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

   ## Which issue does this PR close?
   
   No correlated issue
   
   ## Rationale for this change
   
   The unparser omits the float scalar value information, causing incorrect sql 
from unparser.
   
   When sending a query like 
   ```
   select * from inventory where inv_warehouse_sk between 3.0/2.0 AND 4.0/2.0
   ```
   to Datafusion, the query plan related to the scalar value is 
   ```
   Filter: CAST(inventory.inv_warehouse_sk AS Float64) BETWEEN Float64(3) / 
Float64(2) AND Float64(4) / Float64(2)`. 
   ```
   However, the unparser omits the `Float64()` information, causing wrong query 
from unparser
   ```SQL
   SELECT "inventory"."inv_date_sk", "inventory"."inv_item_sk", 
"inventory"."inv_warehouse_sk", "inventory"."inv_quantity_on_hand" FROM 
"inventory" WHERE (CAST("inventory"."inv_warehouse_sk" AS DOUBLE PRECISION) 
BETWEEN (3 / 2) AND (4 / 2))
   ```
   
   This will cause incorrect data in some engine, for example, in postgres `3 / 
2` is `1` and `3.0/2.0` is `1.5`
   
   ## What changes are included in this PR?
   
   * Add an explicit cast for scalar value of type `Float64` and `Float32` to 
preserve the type information in unparser
   * Add tests to cover the changes
   
   ## Are these changes tested?
   
   Yes
   
   ## Are there any user-facing changes?
   
   User will receive float scalar value that correctly preserves the float 
information.


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