-
Notifications
You must be signed in to change notification settings - Fork 606
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
bigquery: api improvements #2530
bigquery: api improvements #2530
Conversation
@tswast if you have some free time, could you look through this PR to make sure all the P0 items look ok? I also want to mention for CRUD calls on specific properties (labels, timePartitioning, etc.), this all happens through a e.g. var metadata = {
labels: {
foo: 'bar'
}
};
table.setMetadata(metadata, (err, apiResponse) => {
// ...
}); |
packages/bigquery/src/index.js
Outdated
value = parseFloat(value); | ||
break; | ||
} | ||
case 'INTEGER': { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* // Error handling omitted. | ||
* } | ||
* | ||
* job.getQueryResults(function(err, rows) {}); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
packages/bigquery/src/index.js
Outdated
if (options.parameterMode === 'named') { | ||
options.queryParameters = []; | ||
if (query.params) { | ||
reqOpts.useLegacySql = false; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
|
||
var nextQuery = null; | ||
if (resp.jobComplete === false) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* // Error handling omitted. | ||
* } | ||
* | ||
* job.getQueryResults(function(err, rows) {}); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
packages/bigquery/src/index.js
Outdated
* bigquery.createJob().then(function(data) { | ||
* var job = data[0]; | ||
* | ||
* return job.getQueryResults(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
|
||
var nextQuery = null; | ||
if (resp.jobComplete === false) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
callback(null, job, resp); | ||
}); | ||
this.createJob(reqOpts, callback); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@stephenplusplus @tswast I think I'm ready for a final review if you can find some time soon. |
request: function(reqOpts) { | ||
if (reqOpts.method === 'PATCH' && reqOpts.json.etag) { | ||
reqOpts.headers = reqOpts.headers || {}; | ||
reqOpts.headers['If-Match'] = reqOpts.json.etag; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Facing a system test error:
This is a console.log of BigQuery {
makeAuthenticatedRequest:
{ [Function: makeAuthenticatedRequest]
getCredentials: [Function: bound getCredentials],
authClient:
Auth {
authClientPromise: [Object],
authClient: [Object],
config: [Object],
environment: {},
projectId: 'nth-circlet-705' } },
authClient:
Auth {
authClientPromise: Promise { [Object] },
authClient:
JWT {
transporter: DefaultTransporter {},
clientId_: undefined,
clientSecret_: undefined,
redirectUri_: undefined,
opts: {},
credentials: [Object],
email: '[email protected]',
keyFile: undefined,
key: '-----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----\n',
scopes: [Array],
subject: undefined,
gToken: [Function: GoogleToken],
projectId: 'nth-circlet-705',
gtoken: [Object] },
config:
{ baseUrl: 'https://www.googleapis.com/bigquery/v2',
scopes: [Array],
packageJson: [Object] },
environment: {},
projectId: 'nth-circlet-705' },
baseUrl: 'https://www.googleapis.com/bigquery/v2',
getCredentials: [Function: bound getCredentials],
globalInterceptors: [],
interceptors: [],
packageJson: { ... },
projectId: '{{projectId}}',
projectIdRequired: true,
Promise: [Function: Promise] } |
@@ -249,33 +260,13 @@ Dataset.prototype.createTable = function(id, options, callback) { | |||
options = {}; | |||
} | |||
|
|||
var body = extend(true, {}, options, { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
packages/bigquery/test/dataset.js
Outdated
var FAKE_QUERY = 'SELECT * FROM `table`'; | ||
|
||
it('should call through to bigQuery#startQuery', function(done) { | ||
ds.bigQuery.startQuery = function() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
switch (schemaField.type) { | ||
case 'BOOLEAN': | ||
case 'BOOL': { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
break; | ||
} | ||
case 'FLOAT': | ||
case 'FLOAT64': { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
break; | ||
} | ||
case 'INTEGER': | ||
case 'INT64': { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -1064,12 +871,21 @@ Table.prototype.import = function(source, metadata, callback) { | |||
* | |||
* @param {object|object[]} rows - The rows to insert into the table. | |||
* @param {object=} options - Configuration object. | |||
* @param {boolean} options.autoCreate - Automatically create the table if it |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
if (metadata.name) { | ||
metadata.friendlyName = metadata.name; | ||
delete metadata.name; | ||
if (is.fn(metadata)) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
}); | ||
|
||
if (is.fn(metadata)) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
packages/bigquery/test/table.js
Outdated
table.startCopyFrom(SOURCE_TABLE, done); | ||
}); | ||
|
||
it('should pass an error to the callback', function(done) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
packages/bigquery/test/table.js
Outdated
table.bigQuery.createJob = function() {}; | ||
}); | ||
|
||
it('should send the correct API request', function(done) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@dwmclary for whatever reason it won't let me add you as a reviewer, so I hope a friendly ping here will suffice. |
@stephenplusplus in regard to #2530 (comment) - are you using a specific OS/Node version/etc.? I can't reproduce it on my machine. |
Windows 10, Node v8.6.0, npm 5.3.0. It might depend on how you are auth'ing. From request: {
uri: format('{base}/{projectId}/jobs', {
base: 'https://www.googleapis.com/upload/bigquery/v2/projects',
projectId: self.bigQuery.projectId
})
} I'm using ADC, so |
@stephenplusplus ah, gotcha. I'm wondering what the most correct solution here is, initially I would think to call |
That makes sense, re: separate effort. |
@stephenplusplus I think we're still waiting for an approval from @dwmclary, but is there anything else I may have forgotten to tackle in this? |
@callmehiphop want to just merge this? |
Closes #2511
TODOs