berkaysynnada opened a new issue, #12054:
URL: https://github.com/apache/datafusion/issues/12054

   ### Describe the bug
   
   Following query gives the error: 
   
   ```
   SELECT s.*, s.amount * LAST_VALUE(e.rate) AS amount_usd
   FROM sales_global AS s
   JOIN exchange_rates AS e
   ON s.currency = e.currency_from AND
      e.currency_to = 'USD' AND
      s.ts >= e.ts
   GROUP BY s.sn
   ORDER BY s.sn
   ```
   
   `External error: query failed: DataFusion error: Error during planning: 
Invalid functional dependency: FunctionalDependencies { deps: 
[FunctionalDependence { source_indices: [1], target_indices: [0, 1, 2, 3, 4, 5, 
6, 7, 8, 9], nullable: false, mode: Single }] }`
   
   It might be related with #11681, since I reverted the changes in 
`datafusion/expr/src/logical_plan/plan.rs`, and the test passed.
   
   ### To Reproduce
   
   ```
   statement ok
   CREATE TABLE sales_global (
       ts TIMESTAMP,
       sn INTEGER,
       amount INTEGER,
       currency VARCHAR NOT NULL,
       primary key(sn)
   );
   
   statement ok
   CREATE TABLE exchange_rates (
     ts TIMESTAMP,
     sn INTEGER,
     currency_from VARCHAR NOT NULL,
     currency_to VARCHAR NOT NULL,
     rate FLOAT,
     primary key(sn)
   );
   
   query TT
   EXPLAIN SELECT s.*, s.amount * LAST_VALUE(e.rate) AS amount_usd
   FROM sales_global AS s
   JOIN exchange_rates AS e
   ON s.currency = e.currency_from AND
      e.currency_to = 'USD' AND
      s.ts >= e.ts
   GROUP BY s.sn
   ORDER BY s.sn
   ----
   ```
   
   ### Expected behavior
   
   The test should pass
   
   ### Additional context
   
   _No response_


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