anth0ny-x / delta-io-connectors

Connectors for Delta Lake

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delta Lake Logo Connectors

CircleCI

We are building connectors to bring Delta Lake to popular big-data engines outside Apache Spark (e.g., Apache Hive, Presto).

Introduction

This is the repository for Delta Lake Connectors. It includes a library for querying Delta Lake metadata and connectors to popular big-data engines (e.g., Apache Hive, Presto). Please refer to the main Delta Lake repository if you want to learn more about the Delta Lake project.

Building

The project is compiled using SBT. It has the following subprojects.

Delta uber jar

This project generates a single uber jar containing Delta Lake and all it transitive dependencies (except Hadoop and its dependencies).

  • Most of the dependencies are shaded to avoid version conflicts. See the file build.sbt for details on what are not shaded.
  • Hadoop and its dependencies is not included in the jar because they are expected to be present in the deployment environment.
  • To generate the uber jar, run build/sbt core/compile
  • To test the uber jar, run build/sbt coreTest/test

Hive connector

This project contains all the codes needed to make Hive read Delta Lake tables. The connector has two JARs delta-core-shaded-assembly_<scala_version>-0.1.0.jar and hive-delta_<scala_version>-0.1.0.jar. You can use either Scala 2.11 or 2.12. The released JARs are available in the releases page. Please download the JARs for the corresponding Scala version you would like to use.

You can also use the following instructions to build them.

Build JARs

Please skip this section if you have downloaded the connector JARs.

  • To generate the connector jar run
build/sbt -Dsbt.repository.config=build/sbt-config/repositories "++2.11.12 core/package"
build/sbt -Dsbt.repository.config=build/sbt-config/repositories "++2.11.12 hive/package"

The above commands will generate two JARs in the following paths.

core/target/scala-2.11/delta-core-shaded-assembly_2.12-0.1.0-cdh6.3.3.jar
hive/target/scala-2.11/hive-delta_2.12-0.1.0-cdh6.3.3.jar

These two JARs include the Hive connector and all its dependencies. They need to be put in Hive’s classpath.

Setting up Hive

This sections describes how to set up CDH 6.3.3 Hive to load the Delta Hive connector.

Upload the above two JARs to the machine runs Hive Server2. Finally, add the paths of the JARs toHive’s environment variable, HIVE_AUX_JARS_PATH. You can find this environment variable in the hive-env.sh file, whose location is /etc/hive/conf/hive-env.sh on an EMR cluster. This setting will tell Hive where to find the connector JARs.

The following files are also required to be copied into HIVE_AUX_JARS_PATH;

/opt/cloudera/parcels/CDH/jars/chill_2.11-0.9.2.jar
/opt/cloudera/parcels/CDH/jars/kryo-shaded-3.0.3.jar
/opt/cloudera/parcels/CDH/jars/minlog-1.3.0.jar
/opt/cloudera/parcels/CDH/jars/objenesis-2.5.1.jar
/opt/cloudera/parcels/CDH/jars/xbean-asm7-shaded-4.12.jar

Create a Hive table

After finishing setup, you should be able to create a Delta table in Hive.

Right now the connector supports only EXTERNAL Hive tables. The Delta table must be created using Spark before an external Hive table can reference it.

Here is an example of a CREATE TABLE command that defines an external Hive table pointing to a Delta table on s3://foo-bucket/bar-dir.

CREATE EXTERNAL TABLE deltaTable(col1 INT, col2 STRING)
STORED BY 'io.delta.hive.DeltaStorageHandler'
LOCATION '/delta/table/path'

io.delta.hive.DeltaStorageHandler is the class that implements Hive data source APIs. It will know how to load a Delta table and extract its metadata. The table schema in the CREATE TABLE statement must be consistent with the underlying Delta metadata. Otherwise, the connector will throw an error to tell you about the inconsistency.

Frequently asked questions (FAQ)

Supported Hive versions

CDH 6.3.3

Can I use this connector in Apache Spark or Presto?

No. The connector must be used with Apache Hive. It doesn't work in other systems, such as Apache Spark or Presto.

If I create a table using the connector in Hive, can I query it in Apache Spark or Presto?

No. The table created by this connector in Hive cannot be read in any other systems right now. We recommend to create different tables in different systems but point to the same path. Although you need to use different table names to query the same Delta table, the underlying data will be shared by all of systems.

Can I write to a Delta table using this connector?

No. The connector doesn't support writing to a Delta table.

Do I need to specify the partition columns when creating a Delta table?

No. The partition columns are read from the underlying Delta metadata. The connector will know the partition columns and use this information to do the partition pruning automatically.

Why do I need to specify the table schema? Shouldn’t it exist in the underlying Delta table metadata?

Unfortunately, the table schema is a core concept of Hive and Hive needs it before calling the connector.

What if I change the underlying Delta table schema in Spark after creating the Hive table?

If the schema in the underlying Delta metadata is not consistent with the schema specified by CREATE TABLE statement, the connector will report an error when loading the table and ask you to fix the schema. You must drop the table and recreate it using the new schema. Hive 3.x exposes a new API to allow a data source to hook ALTER TABLE. You will be able to use ALTER TABLE to update a table schema when the connector supports Hive 3.x.

Hive has three execution engines, MapReduce, Tez and Spark. Which one does this connector support?

The connector supports MapReduce and Tez. It doesn't support Spark execution engine in Hive.

Reporting issues

We use GitHub Issues to track community reported issues. You can also contact the community for getting answers.

Contributing

We welcome contributions to Delta Lake Connectors repository. We use GitHub Pull Requests for accepting changes.

Community

There are two mediums of communication within the Delta Lake community.

About

Connectors for Delta Lake

License:Apache License 2.0


Languages

Language:Scala 78.1%Language:Java 12.7%Language:Shell 9.2%