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): fix latest by factories not reacting to bind variable value change #3521

Merged
merged 1 commit into from
Jun 29, 2023

Conversation

bziobrowski
Copy link
Contributor

@bziobrowski bziobrowski commented Jun 28, 2023

Fixes a number of latest by factories that cached and used the first bind variable value set.

Example:

CREATE TABLE IF NOT EXISTS tab (
    ts timestamp, 
    sym symbol, 
    isym symbol,
    h string,
    type char,
    stat char
), index(isym) timestamp(ts) partition by MONTH;

insert into tab values 
(0, 'S1', 'S1', 'h1', 'X', 'Y' ), 
(1, 'S2', 'S2', 'h2', 'X', 'Y' ), 
(3, null, null, 'h3', 'X', 'Y' );

select h, isym from 
(select h, stat, isym from tab 
  where sym = ? and type = 'X' latest on ts partition by sym 
) where stat='Y';

Running the last query with "S1" and then "S2" bind variable value or null returns the following in master branch :

h   isym
h1    S1

@ideoma
Copy link
Collaborator

ideoma commented Jun 28, 2023

[PR Coverage check]

😍 pass : 17 / 17 (100.00%)

file detail

path covered line new line coverage
🔵 io/questdb/griffin/engine/table/LatestByValueFilteredRecordCursor.java 1 1 100.00%
🔵 io/questdb/griffin/engine/table/AbstractLatestByValueRecordCursor.java 6 6 100.00%
🔵 io/questdb/griffin/engine/table/LatestByValueRecordCursor.java 1 1 100.00%
🔵 io/questdb/griffin/engine/table/AbstractDeferredValueRecordCursorFactory.java 6 6 100.00%
🔵 io/questdb/griffin/engine/table/LatestByValueIndexedFilteredRecordCursor.java 3 3 100.00%

@puzpuzpuz puzpuzpuz added Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution labels Jun 29, 2023
@ideoma ideoma merged commit f56fe92 into master Jun 29, 2023
25 checks passed
@ideoma ideoma deleted the bz_fix_latest_by_with_bind_var branch June 29, 2023 10:44
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.

None yet

4 participants