Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

hive-driver

lenchv2.3kMIT1.0.0TypeScript support: included

Driver for connection to Apache Hive via Thrift API.

hiveserver2, apache, hive, hs2, kerberos, sasl, ldap, hadoop, client, thrift, nodejs, js, hive, hive js

readme

Hive Driver

npm test coverage

Description

Hive Driver is a Java Script driver for connection to Apache Hive via Thrift API.

This driver can connect with SASL authentication mechanisms (such as LDAP, PLAIN, Kerberos) using both HTTP and TCP transport.

Installation

npm i hive-driver

If you'd like to use Kerberos, you have to install and build the kerberos module on your own

npm i kerberos

Usage

examples/usage.js

const hive = require('hive-driver');
const { TCLIService, TCLIService_types } = hive.thrift;
const client = new hive.HiveClient(
    TCLIService,
    TCLIService_types
);

client.connect(
    {
        host: 'localhost',
        port: 10000
    },
    new hive.connections.TcpConnection(),
    new hive.auth.NoSaslAuthentication()
).then(async client => {
    const session = await client.openSession({
        client_protocol: TCLIService_types.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V10
    });
    const response = await session.getInfo(
        TCLIService_types.TGetInfoType.CLI_DBMS_VER
    );

    console.log(response.getValue());

    await session.close();
}).catch(error => {
    console.log(error);
});

For more details see: Getting Started

Test

Unit tests:

npm run test

e2e tests:

npm run e2e

NOTICE

e2e tests use dockerized Hive instance, for more details see: .docker

Contributing

See CONTRIBUTING.md

Issues

If you find some issues, feel free to create an issue or send a pull request.

License

MIT License

Copyright (c) 2020 Volodymyr Liench

changelog

Changelog

1.0.0 2024-04-21

  • Updated npm modules
  • Added UploadData and DownloadData methods of newest TCLIService.thrift
  • Added npm provenance check

0.3.1 2024-03-15

  • expose flush() in IOperation for proper work with massive data

0.3.0 2023-09-25

  • Upgraded kerberos library

  • Added parameter "orientation" to fetch method in order to force using FETCH_NEXT as first operation after initialization schema

  • Fixed issue when on pending state the error was thrown

  • Fixed issue when in some cases colum was undefined when parsing JsonResult

0.2.0 2022-08-20

  • Fixed an issue with zero-based column start (Spark Thrift Server, Kyuubi, for example)

  • Updated thrift and dev libraries

0.1.5 2021-05-16

  • Added method flush() to operation class, in order to avoid memory allocation errors when working with massive amount of data

  • Added an instruction how to connect via zookeeper using hive-driver

0.1.4 2020-07-03

  • Fixed retrieving null values from the API

0.1.3 2020-03-30

  • Added events to HiveClient: close, reconnecting, timeout

  • Added throwing exception when connection is closed but session is tried to be opened

  • Added method isConnected to the IThriftConnection interface

  • Described in the troubleshooting.md how to reconnect when the connection is lost

0.1.2 2020-02-24

  • Fixed setting response in OperationStateError

0.1.1 2020-02-23

  • Changed version in package.json
  • Fixed retrieving data when Hive does not return hasResultSet
  • Added formatting progressUpdateResponse
  • Added connection example to Azure HDInsight

0.1.0 2020-02-17

  • Implemented methods in HiveDriver for CLIService of HIVE_CLI_SERVICE_PROTOCOL_V11

  • Added HiveClient, HiveSession, HiveOperation for interacation with HiveDriver

  • Added HiveUtils to help retrieving data and present it as JSON

  • Implemented Http and Tcp transports

  • Implemented authentications: NoSASL, Plain, Kerberos

  • Added kerberos authentication process via mongodb kerberos module

  • Implemented SSL secured connection