presto-client
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -23,2 +23,4 @@ var http = require('http'); | ||
this.checkInterval = args.checkInterval || QUERY_STATE_CHECK_INTERVAL; | ||
this.jsonParser = args.jsonParser || JSON; | ||
}; | ||
@@ -46,2 +48,4 @@ | ||
var parser = this.jsonParser; | ||
var req = http.request(opts, function(res){ | ||
@@ -57,3 +61,3 @@ var response_code = res.statusCode; | ||
if (response_code < 300 && (data[0] === '{' || data[0] === '[')) { | ||
try { data = JSON.parse(data); } | ||
try { data = parser.parse(data); } | ||
catch (x) { | ||
@@ -163,2 +167,4 @@ /* ignore json parse error (and don't parse) for non-json content body */ | ||
throw {message: "schema not specified"}; | ||
if (!opts.success && !opts.callback) | ||
throw {message: "callback function 'success' (or 'callback') not specified"}; | ||
@@ -165,0 +171,0 @@ var header = {}; |
{ | ||
"name": "presto-client", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "Distributed query engine Presto client library for node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -58,2 +58,4 @@ # presto-client-node | ||
* interval milliseconds of each RPC to check query status (default: 800ms) | ||
* jsonParser [object] | ||
* custom json parser if required (default: `JSON`) | ||
@@ -158,4 +160,33 @@ return value: client instance object | ||
## BIGINT value handling | ||
Javascript standard `JSON` module cannot handle BIGINT values correctly by precision problems. | ||
```js | ||
JSON.parse('{"bigint":1139779449103133602}').bigint //=> 1139779449103133600 | ||
``` | ||
If your query puts numeric values in its results and precision is important for that query, you can swap JSON parser with any modules which has `parse` method. | ||
```js | ||
var JSONbig = require('json-bigint'); | ||
JSONbig.parse('{"bigint":1139779449103133602}').bigint.toString() //=> "1139779449103133602" | ||
// set client option | ||
var client = new presto.Client({ | ||
// ... | ||
jsonParser: JSONbig, | ||
// ... | ||
}); | ||
``` | ||
## Versions | ||
* 0.1.0: | ||
* add option to pass customized json parser to handle BIGINT values | ||
* add check for required callbacks of query execution | ||
* 0.0.6: | ||
* add API to get/delete queries | ||
* add callback `state` on query execution | ||
* 0.0.5: | ||
* fix to do error check on query execution | ||
* 0.0.4: | ||
@@ -162,0 +193,0 @@ * send cancel request of canceled query actually |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
208
18645
6
295