{"_id":"@dalongrong/trino-client","_rev":"2-aa6959bba2aa5ea9e62cbe8e6413fdc6","name":"@dalongrong/trino-client","dist-tags":{"latest":"1.0.0"},"versions":{"0.9.0":{"name":"@dalongrong/trino-client","version":"0.9.0","description":"Distributed query engine Presto client library for node.js","main":"index.js","scripts":{"p":"yarn publish --access public"},"public":true,"repository":{"type":"git","url":"git://github.com/rongfengliang/presto-client-node.git"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"keywords":["presto","trino"],"author":{"name":"tagomoris,rongfengliang"},"license":"MIT","licenseText":"The MIT License (MIT)\n\nCopyright (c) 2014- tagomoris\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.","_id":"@dalongrong/trino-client@0.9.0","dist":{"shasum":"57ab698c158a5127065a0d0688ca4d6905a91eae","integrity":"sha512-U2+/GMdUz2EHFQuJcnXqrOQhcun14lthNpz9jxN6UvttdgtVnvDNCUnUTHFIY2G9/z6nFQLz4qyfksV6BYJA7Q==","tarball":"https://registry.npmjs.org/@dalongrong/trino-client/-/trino-client-0.9.0.tgz","fileCount":9,"unpackedSize":23398,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdGdQCRA9TVsSAnZWagAA6OQP/i/2y0QkhCRtr0BVe47H\nUYbvqIE7yBs5qncR6WDOx6mXvWzmAnqO+r6X9tMxvXOVy2RGU/trAQ04dsj5\nXmxhKSUBjGQbHOcTdVRVFjLTxeZ3WUdrYitKO5nR0fVF9zN+J5Y4bl8ak7gW\nM4By34USW6VDCYlP0gqziBXktVOzy+MXnlZvurAr2QaRBmNGW1d/hVLHkYXQ\nD/V5fAyVbDVthdC1teh4mPHhlgaMnFubbvve/Xnh9dEMFf31FgrwR5aKTE7k\nQQw+RNxhJWCqECvPvIm5FxJC7WOA2dpVb61URhf8rmeIIyVkRpkucPL0mNC/\nzZiKBH6rAh6UEbe7ZagmJc48xVnsmEbi2WqxyGTipCO88PAPVL9wBO8OIuwG\nPuC2RjTgmgPxbe/2OBMjFlPzUYNWYEcE3z0Fl61YR1L2WCb81LZpi+EmMo2p\nRXBXEN4Ya2YXxLxAOrog/89pYOtH5D7vKQPIupbdLPKM5y/f9xEaU2RASURY\nKusMAOEtmu5xVW0V/0k02zaauEjgulEdDIu8TRDGRP0MdfTIua5kAqS0Uf/D\nXg6wcMTPKXcEIycrBc73x6MVLPkLDHKdG5d9XIEit1GegH8vIV7MmF5XYmBT\n75lDtdq1ckl5a1/Oj1LSONWOG3pdquyqe/fcfX4AE/Ci3xMdQbPX6n+xk019\nNllr\r\n=0d8J\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC/Qw5mPyAYHCItLRm3/8elN+MA1Ir2eDPtV+vrRhMqSAiEA/aE814wcmHYffrC7dw/Ro+a5nuM9Z8ggxJHa62k0seg="}]},"_npmUser":{"name":"dalongrong","email":"1141591465@qq.com"},"directories":{},"maintainers":[{"name":"dalongrong","email":"1141591465@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trino-client_0.9.0_1618241360382_0.8388987616175796"},"_hasShrinkwrap":false},"1.0.0":{"name":"@dalongrong/trino-client","version":"1.0.0","description":"Distributed query engine Presto client library for node.js","main":"index.js","public":true,"repository":{"type":"git","url":"https://github.com/rongfengliang/trino-client"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"scripts":{"p":"yarn publish --access public"},"keywords":["presto","trino"],"author":{"name":"tagomoris,rongfengliang"},"license":"MIT","licenseText":"The MIT License (MIT)\n\nCopyright (c) 2014- tagomoris\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.","_id":"@dalongrong/trino-client@1.0.0","dist":{"shasum":"c117223d66fe3c40601de8fb4cbff02917cd362f","integrity":"sha512-X2yk5B/ApY3Ik9Sw1lAv6MfwlRwGbeWCIIBkoYQQvYiI9ndx8rcyY/Uz57NLDudFctQLorOgDfcNbPKf1rw/1A==","tarball":"https://registry.npmjs.org/@dalongrong/trino-client/-/trino-client-1.0.0.tgz","fileCount":9,"unpackedSize":24818,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDazoehG2rQqoa+dUP8CrZLd5RoeTkjSWHL/NMWZoCICAiEA3WkWgflpK/pmqA4HH6K1dgr7+5Qo7O5uyrsKGTcICjo="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJioHZZACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqtNhAAoVaY346va5PNLcDVtBCfigJbj68dlFn9uDlI4ZGSHD2rsROv\r\n53JNAvqdwtE+AzH6KhNTgkRC2RIEPq3kU7rKDJ5e0hWE1+Sh2fOB9i+nf+1f\r\n5LvCpt37r2g+D53I2rxxH3jdg1rvAyr+JV8FjwqZx22hKToH8gvhG7gcUQYK\r\nkdBs71ky4McQvv8AFXu94WWyYBK1Lt2OxNU9j8fejs3tczNZ1Va83AgCWRHO\r\n0HDE4qgmXJJ64XfVdr0OVCy8rIZCN5MqO168pqyS1LmihwbreOO2DEMTFdZ6\r\nfgfT1jWZa18vz+uH7PMGpx0m7CCFM3I4Ng+Z9FZK2gqSd479BBbJcZhcNJS0\r\nMjYJNVJ8k/raz7hpfugRgZaQ/1Ve59fpYcvm1R6nbiM94MzRAnsZJaxWrWMW\r\nz84yDyqamLa8G2mKHYv/0j3+L9f1Qd75QBHS6dskRHKiF57lyfglej56MMuS\r\n2vzSLgbQc9Us9SZ+ssXeJ4+LvYT/W0iYSSA7ocHo9wXypS6Hk6rf9zMee544\r\nWCUwST9wipG1ShgBy1Ezn1Rwsd2zs2dkzAGa3SUkXbEMecb7G0lXjskziO3L\r\n+D2yguQCEgtGqmCL2iuHokSoSamdxJqyO+KNX6a8ml1buOJkWYy4/M97VGNq\r\ntK4JC/BHyfY1pYw1QJ/Dl7jbQrGaduet95E=\r\n=qK1w\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"dalongrong","email":"1141591465@qq.com"},"directories":{},"maintainers":[{"name":"dalongrong","email":"1141591465@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/trino-client_1.0.0_1654683225329_0.960874858048494"},"_hasShrinkwrap":false}},"time":{"created":"2021-04-12T15:29:20.315Z","0.9.0":"2021-04-12T15:29:20.476Z","modified":"2022-06-08T10:13:45.545Z","1.0.0":"2022-06-08T10:13:45.469Z"},"maintainers":[{"name":"dalongrong","email":"1141591465@qq.com"}],"description":"Distributed query engine Presto client library for node.js","keywords":["presto","trino"],"repository":{"type":"git","url":"https://github.com/rongfengliang/trino-client"},"author":{"name":"tagomoris,rongfengliang"},"license":"MIT","readme":"# presto-client-node\n\n> add Trino support\n\nDistributed query engine \"Trino\" 's client library for node.js.\n\n```js\nvar presto = require('@dalongrong/trino-client');\nvar client = new presto.Client({user: 'myname'});\n\nclient.execute({\n  query:   'SELECT count(*) as cnt FROM tblname WHERE ...',\n  catalog: 'hive',\n  schema:  'default',\n  source:  'nodejs-client',\n  state:   function(error, query_id, stats){ console.log({message:\"status changed\", id:query_id, stats:stats}); },\n  columns: function(error, data){ console.log({resultColumns: data}); },\n  data:    function(error, data, columns, stats){ console.log(data); },\n  success: function(error, stats){},\n  error:   function(error){}\n});\n```\n\n## Installation\n\n```\nnpm install -g presto-client\n```\n\nOr add `presto-client` to your own `package.json`, and do `npm install`.\n\n## API\n\n### new Client(opts)\n\nInstanciate client object and set default configurations.\n\n* opts [object]\n  * host [string]\n    * Presto coordinator hostname or address (default: localhost)\n  * ssl [object]\n    * Setting a Hash object enables SSL and verify server certificate with options (default: `null`):\n      * `ca`: An authority certificate or array of authority certificates to check the remote host against\n      * `cert`: Public x509 certificate to use (default : `null`)\n      * `ciphers` : Default cipher suite to use. (default: https://nodejs.org/api/tls.html#tls_modifying_the_default_tls_cipher_suite)\n      * `key`: Private key to use for SSL (default: `null`)\n      * `passphrase`:  A string of passphrase for the private key or pfx (default: `null`)\n      * `pfx`: Certificate, Private key and CA certificates to use for SSL. (default: `null`).\n      * `rejectUnauthorized`: If not `false` the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if requestCert is `true` (default: `true`)\n      * `secureProtocol`: Optional SSL method to use. The possible values are listed as SSL_METHODS, use the function names as strings. For example, \"SSLv3_method\" to force SSL version 3 (default: `SSLv23_method`)\n      * `servername`: Server name for the SNI (Server Name Indication) TLS extension\n  * port [integer]\n    * Presto coordinator port (default: 8080)\n  * user [string]\n    * Username of query (default: process user name)\n  * source [string]\n    * Source of query (default: nodejs-client)\n  * basic_auth [object]\n    * Pass in a user and password to enable Authorization Basic headers on all requests.\n    * basic_auth: {user: \"user\", password: \"password\"} (default:null)\n  * catalog [string]\n    * Default catalog name\n  * schema [string]\n    * Default schema name\n  * checkInterval [integer]\n    * Interval milliseconds of each RPC to check query status (default: 800ms)\n  * enableVerboseStateCallback [boolean]\n    * Enable more verbose callback for Presto query states (default: false)\n    * When set to `true`, this flag modifies the condition of the state change callback to return data every `checkInterval`(default: 800ms). Modify `checkInterval` if you wish to change the frequency.\n    * Otherwise (`false`), the state change callback will only be called upon a change in state. \n    * The purpose of this variable is to enable verbose update capability in state callbacks. This is such that \"percentage complete\" and \"processed rows\" may be extracted despite the state still remaining in a particular state eg. \"RUNNING\". \n  * jsonParser [object]\n    * Custom json parser if required (default: `JSON`)\n\nreturn value: client instance object\n\n### execute(opts)\n\nThis is an API to execute queries. (Using \"/v1/statement\" HTTP RPC.)\n\nExecute query on Presto cluster, and fetch results.\n\nAttributes of opts [object] are:\n* query [string]\n* catalog [string]\n* schema [string]\n* timezone [string :optional]\n* info [boolean :optional]\n  * fetch query info (execution statistics) for success callback, or not (default false)\n* cancel [function() :optional]\n  * client stops fetch of query results if this callback returns `true`\n* state [function(error, query_id, stats) :optional]\n  * called when query stats changed\n    * `stats.state`: QUEUED, PLANNING, STARTING, RUNNING, FINISHED, or CANCELED, FAILED\n  * query_id\n    * id string like `20140214_083451_00012_9w6p5`\n  * stats\n    * object which contains running query status\n* columns [function(error, data) :optional]\n  * called once when columns and its types are found in results\n  * data\n    * array of field info\n    * `[ { name: \"username\", type: \"varchar\" }, { name: \"cnt\", type: \"bigint\" } ]`\n* data [function(error, data, columns, stats) :optional]\n  * called per fetch of query results (may be called 2 or more)\n  * data\n    * array of array of each column\n    * `[ [ \"tagomoris\", 1013 ], [ \"dain\", 2056 ], ... ]`\n  * columns (optional)\n    * same as data of `columns` callback\n  * stats (optional)\n    * runtime statistics object of query\n* success [function(error, stats, info) :optional]\n  * called once when all results are fetched (default: value of `callback`)\n* error [function(error) :optional]\n  * callback for errors of query execution (default: value of `callback`)\n* callback [function(error, stats) :optional]\n  * callback for query completion (both of success and fail)\n  * one of `callback` or `success` must be specified\n\nCallbacks order (success query) is: columns -> data (-> data xN) -> success (or callback)\n\n### query(query_id, callback)\n\nGet query current status. (Same with 'Raw' of Presto Web in browser.)\n\n* query_id [string]\n* callback [function(error, data)]\n\n### kill(query_id, callback)\n\nStop query immediately.\n\n* query_id [string]\n* callback [function(error) :optional]\n\n### nodes(opts, callback)\n\nGet node list of presto cluster and return it.\n\n* opts [object :optional]\n  * specify null, undefined or `{}` (currently)\n* callback [function(error,data)]\n  * error\n  * data\n    * array of node objects\n\n## BIGINT value handling\n\nJavascript standard `JSON` module cannot handle BIGINT values correctly by precision problems.\n\n```js\nJSON.parse('{\"bigint\":1139779449103133602}').bigint //=> 1139779449103133600\n```\n\nIf 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.\n\n```js\nvar JSONbig = require('json-bigint');\nJSONbig.parse('{\"bigint\":1139779449103133602}').bigint.toString() //=> \"1139779449103133602\"\n// set client option\nvar client = new presto.Client({\n  // ...\n  jsonParser: JSONbig,\n  // ...\n});\n```\n\n## Versions\n\n* 0.9.0:\n  * make \"catalog\" and \"schema\" options optional (need to specify those in queries if omitted)\n* 0.8.1:\n  * fix to specify default ports of http/https if nextUri doesn't have ports\n* 0.8.0:\n  * fix the bug about SSL/TLS handling if redirections are required\n* 0.7.0:\n  * support the change of prestodb 0.226 (compatible with others)\n* 0.6.0:\n  * add X-Presto-Source if \"source\" specified\n* 0.5.0:\n  * remove support for execute(arg, callback) using `/v1/execute`\n* 0.4.0:\n  * add a parameter to call status callback in verbose\n* 0.3.0:\n  * add Basic Authentication support\n* 0.2.0:\n  * add HTTPS support\n* 0.1.3:\n  * add X-Presto-Time-Zone if \"timezone\" specified\n* 0.1.2:\n  * add X-Presto-Session if \"session\" specified\n* 0.1.1:\n  * fix bug not to handle HTTP level errors correctly\n* 0.1.0:\n  * add option to pass customized json parser to handle BIGINT values\n  * add check for required callbacks of query execution\n* 0.0.6:\n  * add API to get/delete queries\n  * add callback `state` on query execution\n* 0.0.5:\n  * fix to do error check on query execution\n* 0.0.4:\n  * send cancel request of canceled query actually\n* 0.0.3:\n  * simple and immediate query execution support\n* 0.0.2: maintenance release\n  * add User-Agent header with version\n* 0.0.1: initial release\n\n## Todo\n\n* node: \"failed\" node list support\n* patches welcome!\n\n## Author & License\n\n* tagomoris\n* License:\n  * MIT (see LICENSE)\n","readmeFilename":"README.md"}