-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
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
goldmedal
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working