Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
presto-client
Advanced tools
Distributed query engine "Presto" 's client library for node.js.
var presto = require('presto-client');
var client = new presto.Client({user: 'myname'});
client.execute({
query: 'SELECT count(*) as cnt FROM tblname WHERE ...',
catalog: 'hive',
schema: 'default',
source: 'nodejs-client',
state: function(error, query_id, stats){ console.log({message:"status changed", id:query_id, stats:stats}); },
columns: function(error, data){ console.log({resultColumns: data}); },
data: function(error, data, columns, stats){ console.log(data); },
success: function(error, stats){},
error: function(error){}
});
npm install -g presto-client
Or add presto-client
to your own package.json
, and do npm install
.
Instanciate client object and set default configurations.
null
):
ca
: An authority certificate or array of authority certificates to check the remote host againstcert
: Public x509 certificate to use (default : null
)ciphers
: Default cipher suite to use. (default: https://nodejs.org/api/tls.html#tls_modifying_the_default_tls_cipher_suite)key
: Private key to use for SSL (default: null
)passphrase
: A string of passphrase for the private key or pfx (default: null
)pfx
: Certificate, Private key and CA certificates to use for SSL. (default: null
).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
)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
)servername
: Server name for the SNI (Server Name Indication) TLS extensionAuthorization
header with the provided string.basic_auth
is also given at the same timetrue
, 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.false
), the state change callback will only be called upon a change in state.JSON
)null
or 0
to disable.return value: client instance object
This is an API to execute queries. (Using "/v1/statement" HTTP RPC.)
Execute query on Presto cluster, and fetch results.
Attributes of opts [object] are:
PREPARE query0 FROM
prefix.queryN
(N: index) like query0
, query1
in the query specified as query
. Example:
client.execute({ query: 'EXECUTE query0 USING 2', prepares: ['SELECT 2 + ?'], /* ... */ });
true
stats.state
: QUEUED, PLANNING, STARTING, RUNNING, FINISHED, or CANCELED, FAILED20140214_083451_00012_9w6p5
[ { name: "username", type: "varchar" }, { name: "cnt", type: "bigint" } ]
[ [ "tagomoris", 1013 ], [ "dain", 2056 ], ... ]
columns
callback502
, 503
, or 504
callback
)callback
)callback
or success
must be specifiedcallback
or error
must be specifiedCallbacks order (success query) is: columns -> data (-> data xN) -> success (or callback)
Get query current status. (Same with 'Raw' of Presto Web in browser.)
Stop query immediately.
Get node list of presto cluster and return it.
{}
(currently)Javascript standard JSON
module cannot handle BIGINT values correctly by precision problems.
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.
var JSONbig = require('json-bigint');
JSONbig.parse('{"bigint":1139779449103133602}').bigint.toString() //=> "1139779449103133602"
// set client option
var client = new presto.Client({
// ...
jsonParser: JSONbig,
// ...
});
When working on this library, you can use the included docker-compose.yml file to spin up a Presto and Trino DBs, which can be done with:
docker compose up
Once you see the following messages, you'll be able connect to Presto at http://localhost:18080
and Trino at http://localhost:18081
, without username/password:
presto-client-node-trino-1 | 2023-06-02T08:12:37.760Z INFO main io.trino.server.Server ======== SERVER STARTED ========
presto-client-node-presto-1 | 2023-06-02T08:13:29.760Z INFO main com.facebook.presto.server.PrestoServer ======== SERVER STARTED ========
After making a change, you can run the available test suite by doing:
npm run test
Authorization
header value directly (for Kerberos, OpenID Connect, etc)/v1/execute
state
on query executionFAQs
Distributed query engine Presto/Trino client library for node.js
We found that presto-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.