Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: For measures using join_to_timespine, apply filters after time spine join #1056

Merged
merged 6 commits into from
Feb 29, 2024

Conversation

courtneyholcomb
Copy link
Contributor

Resolves #1039
Completes SL-1732

Description

For queries using measures that join to time spine, filters were being applied before the time spine join, but not after. This means that there might be additional rows added from the time spine join that should be removed by the filters, resulting in unexpected rows in the output data. Here, we update the DataFlow Plan to apply those filters again after the time spine join, ensuring there will be no unexpected rows in the result.
Note: this means the filters are applied multiple times, which is redundant for the final output but ideally results in a more efficient query.

Copy link

linear bot commented Feb 28, 2024

@cla-bot cla-bot bot added the cla:yes label Feb 28, 2024
@courtneyholcomb courtneyholcomb marked this pull request as ready for review February 28, 2024 16:57
@courtneyholcomb courtneyholcomb requested review from tlento and plypaul and removed request for tlento February 28, 2024 17:00
@courtneyholcomb courtneyholcomb added the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Feb 28, 2024
@github-actions github-actions bot removed the Run Tests With Other SQL Engines Runs the test suite against the SQL engines in our target environment label Feb 28, 2024
Copy link
Contributor

@tlento tlento left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, the inline is just me double-checking that we're rendering faithfully even if the input might be odd.

Comment on lines +48 to +51
metric_time__day BETWEEN '2020-01-03' AND '2020-01-05'
) AND (
metric_time__day > '2020-01-01'
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just an artifact of passing both a time constraint and a where filter on metric_time in the same query, right? Because if the filter in the query was metric_time__day = '2020-01-01' then this would return the empty set, but that's actually what the constraint combination would tell us to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I knew it was weird when I wrote this test case but I just wanted to make sure both filters got rendered 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But also it won't return an empty dataset since '2020-01-03' through '2020-01-05' is > '2020-01-01'!

@courtneyholcomb courtneyholcomb merged commit ad9d192 into main Feb 29, 2024
9 checks passed
@courtneyholcomb courtneyholcomb deleted the court/timespine-join-filter branch February 29, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SL-1732] [Bug] Where filter is applied to inner query when using join_to_timespine
2 participants