DataJunction / dj

A metrics platform.
http://datajunction.io
MIT License
29 stars 13 forks source link

Query for complex dimension join fails because it doesn't SELECT enough columns #1037

Open anhqle opened 3 weeks ago

anhqle commented 3 weeks ago

Example: Join a fact Transform with a allocation Dimension with a complex dimension link, e.g.

fact.event_timestamp BETWEEN allocation.window_start and allocation.window_end

The constructed query looks like

SELECT
FROM (SELECT * FROM source1) AS fact
JOIN (SELECT ... FROM source2) AS allocation
ON fact.event_timestamp BETWEEN allocation.window_start and allocation.window_end

It seems that DJ tries to be smart and only select what's needed inside of SELECT ... FROM source2. However, it's not smart enough while parsing the complex join condition to realize that window_start and window_end are needed. This causes an invalid SQL, namely Column allocation.window_start and allocation.window_end not found.`