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

fix(sql): improve WITHIN operator validation #3177

Merged
merged 2 commits into from
Apr 12, 2023
Merged

fix(sql): improve WITHIN operator validation #3177

merged 2 commits into from
Apr 12, 2023

Conversation

bziobrowski
Copy link
Contributor

Fixes #3159

WITHIN operator works only when there's :

  • LATEST ON clause
  • PARTITION BY clause uses only indexed symbol columns
  • other filters can be either ignored (evalaute to true) or replaced with interval scan

Instead of silently ignoring operator when conditions aren't met (and returning wrong results) this PR throws an error .
Another quirk of WITHIN is that it is applied after LATEST BY, which is really unexpected for a WHERE clause element, so I added a warning in https://github.com/questdb/questdb.io/pull/1536 .

@ideoma
Copy link
Collaborator

ideoma commented Apr 12, 2023

[PR Coverage check]

😍 pass : 25 / 26 (96.15%)

file detail

path covered line new line coverage
🔵 io/questdb/griffin/engine/table/LatestByAllIndexedRecordCursor.java 11 12 91.67%
🔵 io/questdb/griffin/WhereClauseParser.java 4 4 100.00%
🔵 io/questdb/griffin/SqlCodeGenerator.java 10 10 100.00%

@ideoma ideoma merged commit d705bbc into master Apr 12, 2023
17 checks passed
@ideoma ideoma deleted the bz_fix_within branch April 12, 2023 15:18
@puzpuzpuz puzpuzpuz added Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution labels Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Within operator returns bad results
4 participants