{"id":15492130,"url":"https://github.com/imjuni/jshs2","last_synced_at":"2025-08-20T12:32:16.077Z","repository":{"id":19170417,"uuid":"22402616","full_name":"imjuni/jshs2","owner":"imjuni","description":"jsHS2 is a node.js client driver for hive server 2","archived":false,"fork":false,"pushed_at":"2021-05-21T15:16:02.000Z","size":232,"stargazers_count":34,"open_issues_count":5,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T10:27:08.992Z","etag":null,"topics":["cdh-hive","hiveserver2","thrift"],"latest_commit_sha":null,"homepage":"http://imjuni.github.io/jshs2/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imjuni.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-30T01:03:59.000Z","updated_at":"2023-08-07T03:21:08.000Z","dependencies_parsed_at":"2022-08-21T00:10:27.569Z","dependency_job_id":null,"html_url":"https://github.com/imjuni/jshs2","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fjshs2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fjshs2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fjshs2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fjshs2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imjuni","download_url":"https://codeload.github.com/imjuni/jshs2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230423564,"owners_count":18223435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdh-hive","hiveserver2","thrift"],"created_at":"2024-10-02T07:58:57.094Z","updated_at":"2024-12-19T11:13:11.789Z","avatar_url":"https://github.com/imjuni.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"JSHS2\n----\n\n# Introduction\nJSHS2 is a node.js client driver for hive server 2. See test/PromiseTest.js, for an example of how to use it. JSHS2 reference from pyhs2 after rewrite javascript. But some feature modify suitable for javascript(ex\u003e Promise support).\n\nJSHS2 include IDL(Interface Description Language). For example, Thrift_0.9.2_Hive_1.1.0 in idl directory.\n\n# Important\nIf you want to use JSHS2, You must change hive server 2 configuration. See [Hive Security Configuration](https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2#SettingUpHiveServer2-Authentication/SecurityConfiguration), after change `hive.server2.authentication` value to NOSASL. If you meet connection timeout or querying timeout, most case you don't set NOSASL mode. Because hive server 2 default option is SASL mode.\n\n```\n\u003c!-- in conf/hive-site.xml, change configuration restart hive server --\u003e\n\n\u003cconfiguration\u003e\n  \u003cproperty\u003e\n    \u003cname\u003ehive.exec.authentication\u003c/name\u003e\n    \u003cvalue\u003eNOSASL\u003c/value\u003e\n  \u003c/property\u003e\n\u003c/configuration\u003e\n```\n\n# What is differenc node-java with Hive JDBC between jshs2?\nJDBC connect hive via node-java (using C++ JNI interface). JDBC don't need to set NOSASL, and fully support Apache communify. But JDBC query connection, execution that is some slow because node-jav JNI interface not fast furthermore JDBC need so much loop. If you need execute heavy query that don't suitable for your need.\n\n# Breaking Change\nJSHS2 0.4.0 refactoring to Node.js 7.x. JSHS2 develop using by [ES2015](https://github.com/lukehoban/es6features#readme) feature. For example Class, Destructuring, etc...\n\nIf you use under Node.js 7.x, use JSHS2 0.3.1.\n\n\n# I need help!\nAnd I need your help. JSHS2 is not implementation SASL. I hope that someone add SASL on this project.\nContact imjuni@gmail.com with questions\n\n# Install\n```\nnpm i jshs2 --save\n```\n\n# Option\n## Code\n```js\nconst options = {\n  // Connection configuration\n  auth: 'NOSASL',\n  host: '101.102.103.104',           // HiveServer2 hostname\n  port: '12340',                     // HiveServer2 port\n  timeout: 10000,                    // Connection timeout\n  username: 'jshs2tester',           // HiveServer2 user\n  password: '',                      // HiveServer2 password\n  hiveType: HS2Util.HIVE_TYPE.HIVE,  // HiveServer2 type, (Hive or CDH Hive)\n  hiveVer: '1.1.0',                  // HiveServer2 Version\n  thriftVer: '0.9.2',                // Thrift version at IDL Compile time\n\n  // maybe if you need chdVer below after line\n  cdhVer: '5.3.0',\n\n  // Cursor configuration\n  maxRows: 5120,\n  nullStr: 'NULL',\n  i64ToString: true,\n};\n\n\nconst configure = new Configuration(options);\nconst idl = new IDLContainer();\n\nidl.initialize(configure).then(() =\u003e {\n  // your code, ...\n});\n```\n\n## Description\nConfigure new class. It contain connection configuration and cursor configuration.\n\n* auth - using auth mechanisms. At now only support 'NOSASL'\n* host - hive server2 ip address or domain\n* port - hive server2 port\n* timeout - timeout for connect function\n* username - username for hive server, maybe that logging username on hive server\n* hiveType - Hive Type, CDH or not (that is hive).\n* thriftVer - using thrift version\n* cdhVer - if you using CDH, describe version parameter\n* maxRows - fetch size\n* nullStr - Maybe column value is NULL, replace nullStr. Default value is 'NULL'.\n* i64ToString - javascript number type present floating number. So, i64 interger value cannot display using number. If you enable this flag,\n\n# Hive in CDH\ngetLog function is difference between vanilla Hive and Hive in CDH(CDH Hive).\nCDH Hive must support Hue. And that is display query operation status. So,\nCloudera is add GetLog api on hive.\n\nIf you using CDH Hive, describe hiveType 'cdh' after you using getLog function.\nReference Simple Usage\n\n# Interface Description Language(IDL)\nHive support thrift protocol, that is using by IDL. jshs2 can use your idl(idl for your\nenvironment). See under idl directory that was created using by simple rule.\n\n* Use Hive in CDH\n    * /idl/Thrift\\__[Thrift version]_\\_Hive\\__[Hive version]_\\_CDH\\__[CDH version]_\n* Use Vanilla Hive\n    * /idl/Thrift\\__[Thrift version]_\\_Hive\\__[Hive version]_\n\n## jsHS2 include \u0026 Test\n* Thrift_0.9.2_Hive_0.13.1_CDH_5.3.0\n* Thrift_0.9.2_Hive_1.0.0\n* Thrift_0.9.2_Hive_1.1.0\n* Thrift_0.9.2_Hive_1.2.0\n* Thrift_0.9.2_Hive_1.2.1\n* Thrift_0.9.2_Hive_2.0.0\n* Thrift_0.9.3_Hive_1.0.0\n* Thrift_0.9.3_Hive_1.1.0\n* Thrift_0.9.3_Hive_1.2.0\n* Thrift_0.9.3_Hive_1.2.1\n* Thrift_0.9.3_Hive_2.0.0\n* Thrift_0.9.3_Hive_2.1.0\n\n## Custom IDL\nInterface file compile from Hive(hive-0.13.1-cdh5.3.0/service/if). After copy and rename\njshs2 idl directory, And You specify version. That is it!\n\n# Test\n```bash\n# Create cluster.json file, after modify value by your environment\n$ cp cluster.json.sample cluster.json\n\n$ npm run test     # without debug message\n$ npm run test:msg # with debug message\n```\n\n# Example\n```js\nconst fs = require('fs');\nconst co = require('co');\nconst expect = require('chai').expect;\nconst debug = require('debug')('jshs2:PromiseTest');\nconst jshs2 = require('../index.js');\n\nconst HS2Util = jshs2.HS2Util;\nconst IDLContainer = jshs2.IDLContainer;\nconst HiveConnection = jshs2.HiveConnection;\nconst Configuration = jshs2.Configuration;\n\nconst config = JSON.parse(fs.readFileSync('./cluster.json.sample'));\nconst options = {};\n\noptions.auth = config[config.use].auth;\noptions.host = config[config.use].host;\noptions.port = config[config.use].port;\noptions.timeout = config[config.use].timeout;\noptions.username = config[config.use].username;\noptions.hiveType = config[config.use].hiveType;\noptions.hiveVer = config[config.use].hiveVer;\noptions.cdhVer = config[config.use].cdhVer;\noptions.thriftVer = config[config.use].thriftVer;\n\noptions.maxRows = config[config.use].maxRows;\noptions.nullStr = config[config.use].nullStr;\noptions.i64ToString = config[config.use].i64ToString;\n\nco(function* coroutine() {\n  const execResult = yield cursor.execute(config.Query.query);\n\n  for (let i = 0, len = 1000; i \u003c len; i += 1) {\n    const status = yield cursor.getOperationStatus();\n    const log = yield cursor.getLog();\n\n    debug('wait, status -\u003e ', HS2Util.getState(serviceType, status));\n    debug('wait, log -\u003e ', log);\n\n    if (HS2Util.isFinish(cursor, status)) {\n      debug('Status -\u003e ', status, ' -\u003e stop waiting');\n\n      break;\n    }\n\n    yield HS2Util.sleep(5000);\n  }\n\n  debug('execResult -\u003e ', execResult);\n\n  let fetchResult;\n  if (execResult.hasResultSet) {\n    const schema = yield cursor.getSchema();\n\n    debug('schema -\u003e ', schema);\n\n    fetchResult = yield cursor.fetchBlock();\n\n    debug('first row -\u003e', JSON.stringify(fetchResult.rows[0]));\n    debug('rows -\u003e', fetchResult.rows.length);\n    debug('rows -\u003e', fetchResult.hasMoreRows);\n  }\n\n  return {\n    hasResultSet: execResult.hasResultSet,\n    rows: (execResult.hasResultSet) ? fetchResult.rows : [],\n  };\n}).then((data) =\u003e {\n  console.log(data);\n}).catch((err) =\u003e {\n  debug('Error caused, ');\n  debug(`message:  ${err.message}`);\n  debug(`stack:  ${err.stack}`);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjuni%2Fjshs2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimjuni%2Fjshs2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjuni%2Fjshs2/lists"}