Skip to main content

Apache Hive Reference

Authentication options and data type handling for Hive connections.

Server​

servers:
- server: production
type: hive
host: hive.acme.com
port: 10000
database: sales

Authentication​

VariableExampleDescription
DATACONTRACT_HIVE_USERNAMEanalystUsername. Defaults to hive
DATACONTRACT_HIVE_PASSWORDmysecretpasswordPassword. Defaults to hive
DATACONTRACT_HIVE_AUTH_MECHANISMLDAPPLAIN (default), NOSASL, LDAP, or GSSAPI (Kerberos)
DATACONTRACT_HIVE_USE_SSLtrueWhether to use TLS. Defaults to false
DATACONTRACT_HIVE_USE_HTTP_TRANSPORTtrueUse HTTP transport (hive.server2.transport.mode=http) instead of binary thrift. Defaults to false
DATACONTRACT_HIVE_HTTP_PATHcliserviceHTTP path of HiveServer2 for HTTP transport. Defaults to empty

The defaults fit a HiveServer2 with hive.server2.authentication=NONE, which still expects a SASL PLAIN handshake with any user name. The connection goes through the impyla driver.

host, port, and database come from the contract's servers block, and can be overridden with DATACONTRACT_HIVE_HOST, DATACONTRACT_HIVE_PORT, and DATACONTRACT_HIVE_DATABASE. port defaults to 10000.

Data types​

Importing​

datacontract import hive reads DESCRIBE FORMATTED and takes the declared type as the physicalType: STRING/VARCHAR/CHAR → string, INT/BIGINT/SMALLINT/TINYINT → integer, FLOAT/DOUBLE/DECIMAL → number, BOOLEAN → boolean, DATE → date, TIMESTAMP → timestamp, ARRAY<...> → array, STRUCT<...> → object, MAP<...> → map, BINARY → string. Partition columns are imported with the other columns.

Testing​

Hive supports native type introspection: the declared physicalType is checked against DESCRIBE. Length/precision is only enforced when the contract declares it (varchar matches varchar(10)), and the fields of a struct and the element type of an array are compared too.