Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Redshift: anyone knows? #45

Open
unlucio opened this issue Oct 29, 2018 · 4 comments
Open

Redshift: anyone knows? #45

unlucio opened this issue Oct 29, 2018 · 4 comments

Comments

@unlucio
Copy link

unlucio commented Oct 29, 2018

Hello,
I was trying to use this against a redshift instance with the following test script:

const { Pool } = require('pg');
const config = require('./src/lib/config');
const credentials = config.get('warehousedb');

const pool = new Pool({
    user: credentials.user,
    host: credentials.host,
    database: credentials.name,
    password: credentials.pass,
    port: credentials.port
});

function consumeCursor(cursor, cb, done) {
    console.log('consumeCursor invocation');
    cursor.read(100, (error, rows) => {
        if (error) {
            done(error);
            return;
        }

        if (rows.length < 1 ) {
            console.log('Cursor is empty, all done!');
            done();
            return;
        }

        cb(rows);
        consumeCursor(cursor, cb, done);
    });
}

const query = 'select * from <table_name> LIMIT 1000';

pool.connect().then(function(client) {
    console.log('creating cursor');
    const cursor = client.query(new Cursor(query));

    function done(error) {
        if (error) {
            console.error('Cursor boom: ', error);
        }

        console.log('done!');
        cursor.close(() => client.release());
    }

    function push(result = []) {
        console.log('Got results: ', result.length);
    }

    consumeCursor(cursor, push, done);
});

and behold of the result:

creating cursor
consumeCursor invocation
Got results:  1000
consumeCursor invocation
Cursor is empty, all done!
done!

So here's what's confusing me:

  • As shown from Got results: 1000 I guess Redshift might not be playing ball?
  • Now, why Got results: 1000 if I'm asking to read 100 items? I tried removing the LIMIT 1000 as well but there was no change.

I haven't got any time yet to read node-pg-cursor yet so I def might be miss-understanding something, so apologie for something I might have missed.

@unlucio
Copy link
Author

unlucio commented Oct 29, 2018

ok, seems like this might be the answer to my questions https://github.com/brianc/node-pg-cursor/blob/master/index.js#L138 :/ 🤷‍♂️

@unlucio
Copy link
Author

unlucio commented Nov 6, 2018

I assume no one else is interested in a redshift support?

@mikl
Copy link
Contributor

mikl commented Dec 4, 2018

@unlucio did you see #14? PR #44 might solve your problem.

@ysfdev
Copy link

ysfdev commented Dec 26, 2018

Hi,

It's any of the maintainers planning to merge PR #44? I also tested locally and the new changes from #44 seems to fix the Streaming issues.

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

No branches or pull requests

3 participants