GoHive: A Hive Driver for Go
Go programmers usually call the standard package
database/sql to access databases.
database/sql relies on database drivers to work with database management systems. A growing list of drivers is at https://github.com/golang/go/wiki/SQLDrivers, where we cannot find one for Apache Hive at the moment we wrote this package.
Walkthrough the Code
As required by
gohive.Driverthat implements the
database/sql/driver.Driverinterface, which has a method
init()method registers the type
database/sql/driver.Driveris supposed to return a connection, which is a type that implements the
connection.godefines the type
database/sql/driver.QueryerContextby defining method
QueryContextto run queries and to return rows.
gohive.Rowsthat implements the interface
Access Hive through Thrift
For contributors who are curious how this driver talks to Hive via its Thrift interface, here is Hive’s Thrift service definition.
Running Hive in Containers
For the convenience of the development of this package, we provide Dockerfiles that install and run Hive in Docker containers.