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

Is createQueryStream removed or is it just not working in v2 #303

Closed
RubenLaube-Pohto opened this issue Dec 11, 2018 · 8 comments
Closed
Assignees
Labels
api: bigquery Issues related to the googleapis/nodejs-bigquery API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@RubenLaube-Pohto
Copy link

RubenLaube-Pohto commented Dec 11, 2018

I was using createQueryStream in the 1.3 version. After updating to v2 the call does not work correctly anymore. It seems to start but then something goes wrong (see pic). The query string is passed in and is valid as it can be logged before the call and v1.3 works.

The v2 documentation does not mention createQueryStream anymore. Does that mean it was removed? The removal is not marked as a breaking change in the changelog.

image

Environment details

  • OS: Running in GAE
  • Node.js version: 10
  • npm version:
  • @google-cloud/bigquery version: 2

Steps to reproduce

  1. Use createQueryStream in v1.3
  2. Update to v2. Call seems to start but soon causes errors.

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@JustinBeckwith JustinBeckwith added triage me I really want to be triaged. 🚨 This issue needs some love. labels Dec 12, 2018
@nynexman4464
Copy link

This is really frustrating after #120 was closed and not announced what release it would appear in.

@JustinBeckwith JustinBeckwith added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Dec 18, 2018
@JustinBeckwith JustinBeckwith removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Dec 18, 2018
@jkwlui
Copy link
Member

jkwlui commented Dec 18, 2018

This is really frustrating after #120 was closed and not announced what release it would appear in.

@nynexman4464 it was released as part of v2.0.0. You can view the release notes here. Sorry for the confusion!

As for the createQueryStream method, we haven't removed it in v2, rather there was a mistake in the generation of the docs that causes it to be missing from the documentation. The signature of the method should have remained unchanged between v1.3 and v2.0.

To help us figure out what is wrong, @RubenLaube-Pohto could you provide some code showing how you're calling createQueryStream?

@JustinBeckwith JustinBeckwith added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Dec 19, 2018
@nynexman4464
Copy link

nynexman4464 commented Dec 19, 2018

This simple example breaks with the "A SQL query string is required" message

  let bigquery = new BigQuery({
    projectId,
    keyFilename: /*omit*/,
  });
  const query = `
#standardSQL
SELECT country_code, name
FROM \`countries\`;`;
  bigquery.createQueryStream({ query }).on('error', error => {
      console.error(error);
    }).on('data', row => {
      console.log(row);
    }).on('end', () => {
      console.log('end');
    });

I ended up switching to createQueryJob and getQueryResultsStream combo which seems to work.

@RubenLaube-Pohto
Copy link
Author

I was unfortunately unable to recreate the issue. I tried to recreate the basic idea of my app as simply as I could but it did run without errors. The actual app is a bit complex, maybe overly so. The issue I had instead was that on GAE the smallest instance ran out of memory with the example. My deployed app would get that too but I thought it would just be the complexity of the app.

I was able to run my deployed app locally (Ubuntu 16.04 + node10 + bq v2 with Datastore saves disabled) but the deploy is the one breaking if using node10 + bq v2.

const express = require('express');
const { BigQuery } = require('@google-cloud/bigquery');

const app = express();
const client = new BigQuery({
    projectId
});

const validQuery;
 
function runQuery() {
    return new Promise((resolve, reject) => {
        client.createQueryStream(validQuery)
            .on('error', (err) => {
                console.error(err);
                reject(err);
            })
            .on('data', (data) => {
                console.log(data);
            })
            .on('end', () => {
                console.log('complete');
                resolve();
            });
    });
}

app.get('/', 
    async (req, res, next) => {
        await runQuery();
        res.sendStatus(200);
    }
);

app.listen(process.env.PORT || 8080, () => {
    console.log('server started');
});

@jkwlui
Copy link
Member

jkwlui commented Dec 22, 2018

v2.0.5 has just been released which should resolve this issue, sorry for the trouble!

@jkwlui jkwlui closed this as completed Dec 22, 2018
@RubenLaube-Pohto
Copy link
Author

Just updated and the issue is not showing up anymore. Thanks! 👍

@oliverwoodings
Copy link

@kinwa91 v2.0.5 didn't fix this for me unfortunately. I ended up following what @nynexman4464 did and switched to using createQueryJob + getQueryResultsStream, which does work. I am unable to provide a reproduceable test case, but i did do some code diving. This is what i found:

This is as far as I got before resorting to manually using createQueryJob and getQueryResultsStream.

@stephenplusplus
Copy link
Contributor

Thanks for digging-- let me take a look 🔎

@google-cloud-label-sync google-cloud-label-sync bot added the api: bigquery Issues related to the googleapis/nodejs-bigquery API. label Jan 31, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/nodejs-bigquery API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

7 participants