swift-hive-metastore

Client API to access a Hive metastore

License

License

GroupId

GroupId

com.facebook
ArtifactId

ArtifactId

swift-hive-metastore
Last Version

Last Version

2.0
Release Date

Release Date

Type

Type

jar
Description

Description

swift-hive-metastore
Client API to access a Hive metastore
Project URL

Project URL

https://github.com/facebook/swift-hive-metastore
Project Organization

Project Organization

Facebook, Inc.
Source Code Management

Source Code Management

https://github.com/facebook/swift-hive-metastore

Download swift-hive-metastore

How to add to project

<!-- https://jarcasting.com/artifacts/com.facebook/swift-hive-metastore/ -->
<dependency>
    <groupId>com.facebook</groupId>
    <artifactId>swift-hive-metastore</artifactId>
    <version>2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.facebook/swift-hive-metastore/
implementation 'com.facebook:swift-hive-metastore:2.0'
// https://jarcasting.com/artifacts/com.facebook/swift-hive-metastore/
implementation ("com.facebook:swift-hive-metastore:2.0")
'com.facebook:swift-hive-metastore:jar:2.0'
<dependency org="com.facebook" name="swift-hive-metastore" rev="2.0">
  <artifact name="swift-hive-metastore" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.facebook', module='swift-hive-metastore', version='2.0')
)
libraryDependencies += "com.facebook" % "swift-hive-metastore" % "2.0"
[com.facebook/swift-hive-metastore "2.0"]

Dependencies

compile (16)

Group / Artifact Type Version
io.airlift : configuration jar 0.83
io.airlift : log jar 0.83
io.airlift : units jar 0.83
javax.validation : validation-api jar 1.1.0.Final
com.google.guava : guava jar 15.0
org.apache.thrift : libthrift jar 0.9.1
com.facebook.nifty : nifty-client jar 0.10.0
com.google.inject : guice jar 3.0
com.google.inject.extensions : guice-throwingproviders jar 3.0
com.facebook.swift : swift-annotations jar 0.10.0
com.facebook.swift : swift-codec jar 0.10.0
com.facebook.swift : swift-service jar 0.10.0
com.google.code.findbugs : annotations jar 2.0.2
org.apache.hive : hive-serde Optional jar 0.11.0
org.apache.hive : hive-common Optional jar 0.11.0
org.apache.hive : hive-shims Optional jar 0.11.0

provided (1)

Group / Artifact Type Version
org.apache.hadoop : hadoop-core Optional jar 0.20.2

test (5)

Group / Artifact Type Version
junit : junit jar 4.11
org.testng : testng jar 6.8.7
io.airlift : testing jar 0.83
io.airlift : log-manager jar 0.83
io.airlift : bootstrap jar 0.83

Project Modules

There are no modules declared in this project.

swift-hive-metastore

A swift based client for the Hive Metastore. Swift is an annotation based implementation for the Thrift protocol, available from https://github.com/facebook/swift.

Goal of this project is to replace

<dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-metastore</artifactId>
</dependency>

as a client library for users of the Hive metastore.

Only supports Thrift based metastores, there is no support for a local metastore. This is intentional to enforce usage of the Thrift API for clients.

The library is supposed to be an API drop-in, it also supports a number of helper APIs from the hive-metastore dependency:

  • org.apache.hadoop.hive.metastore.MetaStoreUtils
  • org.apache.hadoop.hive.metastore.api.hive_metastoreConstants
  • org.apache.hadoop.hive.metastore.TableType
  • org.apache.hadoop.hive.metastore.MetaStoreFS
  • org.apache.hadoop.hive.metastore.ProtectMode
  • org.apache.hadoop.hive.metastore.Warehouse

All client pieces that are different from the Apache Hive Metastore are located in the com.facebook.hive.metastore package.

Usage

HiveMetastoreClientConfig metastoreConfig = new HiveMetastoreClientConfig();
try (ThriftClientManager clientManager = new ThriftClientManager()) {
    ThriftClientConfig clientConfig = new ThriftClientConfig();
    HiveMetastoreFactory factory = new SimpleHiveMetastoreFactory(clientManager, clientConfig, metastoreConfig);

    try (HiveMetastore metastore = factory.getDefaultClient()) {
        Table table = metastore.getTable("hello", "world");

    }
}

The Metastore API uses new API names (Java style). For drop-in compatibility, use

HiveMetastoreClientConfig metastoreConfig = new HiveMetastoreClientConfig();
try (ThriftClientManager clientManager = new ThriftClientManager()) {
    ThriftClientConfig clientConfig = new ThriftClientConfig();
    HiveMetastoreFactory factory = new SimpleHiveMetastoreFactory(clientManager, clientConfig, metastoreConfig);

    try (HiveMetastore metastore = factory.getDefaultClient()) {
        ThriftHiveMetastore.Client client = ThriftHiveMetastore.Client.forHiveMetastore(metastore);
        Table table = client.get_table("hello", "world");

    }
}

Using Guice

A Guice module is available that allows integration of the client using dependecy injection with Googl Guice. This requires the ThriftClientModule and the ThriftCodecModule from swift.

Injector inj = Guice.createInjector(Stage.PRODUCTION, 
                                    new HiveMetastoreClientModule(),
                                    new ThriftClientModule(),
                                    new ThriftCodecModule());

HiveMetastoreProvider provider = inj.getInstance(HiveMetastoreProvider.class);
HiveMetastore metastore = metastoreProvider.get();

Table table = metastore.getTable("hello", "world");
...

Known problems

Swift does not support unions yet. So ColumnStatisticsData, ColumnStatisticsObj and the associated API calls are not available. This will be fixed in the next release.

com.facebook

Facebook

We are working to build community through open source technology. NB: members must have two-factor auth.

Versions

Version
2.0
1.1
1.0