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

Continuations ignored for query #3100

Closed
ohadzeliger opened this issue Feb 4, 2025 · 1 comment · Fixed by #3111
Closed

Continuations ignored for query #3100

ohadzeliger opened this issue Feb 4, 2025 · 1 comment · Fixed by #3111

Comments

@ohadzeliger
Copy link
Contributor

Summary:
Specifying maxRows:1 for recursive query has no effect
Steps To Reproduce:

  1. Look at cte.yamsql
  2. Add maxRows:1 to the test:
    • query: with c1 as (select col1, col2 from t1) select col1, col2 from c1
    • maxRows: 1
    • unorderedResult: [{COL1: 10, COL2: 1},
      {COL1: 10, COL2: 2},
      {COL1: 20, COL2: 6},
      {COL1: 20, COL2: 7}]
  3. The test still passes

Note: The same happens for UPDATE queries.

@hatyo
Copy link
Contributor

hatyo commented Feb 6, 2025

Please note the above query is a normal common table expression (not recursive), I tried to run it with the following configuration and it failed as expected:

- query: with c1 as (select col1, col2 from t1) select col1, col2 from c1
- maxRows: 1
- unorderedResult: [{COL1: 10, COL2: 1},
        {COL1: 10, COL2: 2},
        {COL1: 20, COL2: 6},
        {COL1: 20, COL2: 7}]

On the other hand, continuations are indeed not handled correctly in case of recursive CTE, the reason is that any user-defined row limit and skip set in the execution properties are ignored in the underlying recursive union cursor logic. I made a this PR #3111 to fix exactly that, and with it, continuations now work as expected for recursive CTEs. Example:

- query: with recursive c1 as (
            select id, parent from t1 where parent = -1
            union all
            select b.id, b.parent from c1 as a, t1 as b where a.id = b.parent) select id from c1
- maxRows: 1
- result: [{ID: 1}]
- result: [{ID: 10}]
- result: [{ID: 20}]
- result: [{ID: 40}]
- result: [{ID: 50}]
- result: [{ID: 70}]
- result: [{ID: 100}]
- result: [{ID: 210}]
- result: [{ID: 250}]
- result: []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants