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

maxRows option for executeStatement is not taken into account #269

Open
quadristan opened this issue Nov 6, 2024 · 1 comment
Open

maxRows option for executeStatement is not taken into account #269

quadristan opened this issue Nov 6, 2024 · 1 comment

Comments

@quadristan
Copy link

quadristan commented Nov 6, 2024

Version

I am using the 1.8.4 version

Description

We want to limit the amount of RAM usage. passing a default maxRows option has no effect, the whole query is returned

How to reproduce

    const operation = await this.session.executeStatement(
      `WITH numbers AS (
    SELECT num
    FROM (SELECT EXPLODE(SEQUENCE(1, 100)) AS num) AS seq
)
SELECT num
FROM numbers
ORDER BY RAND()`,
      { maxRows: 10 },
    );
    const fetched = await operation.fetchAll();
    console.log(fetched.length);

You will notice here that fetched has a size of 100, not 10.

Workaround

The workaround is to use fetchChunk instead:

const chunk = await operation.fetchChunk({
        maxRows: limit - result.length,
      });

Please deprecate or fix maxRows options for the executeStatement method of the session object

@kravets-levko
Copy link
Contributor

Hi @quadristan! Your question is a duplicate of #86 and #155 - please read it. In short - maxRows in executeStatement is related to direct results feature and provides a hint to server about how much data it can return immediately

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

No branches or pull requests

2 participants