Skip to content

Commit c260afe

Browse files
committed
Implements the Delta Lake source with support for splitting
1 parent eb29f86 commit c260afe

12 files changed

Lines changed: 3055 additions & 5 deletions

File tree

sdks/java/io/delta/build.gradle

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@
1919
plugins { id 'org.apache.beam.module' }
2020
applyJavaNature(
2121
automaticModuleName: 'org.apache.beam.sdk.io.delta',
22-
// Latest version of the Delta Kernel API requires Java 17.
2322
requireJavaVersion: JavaVersion.VERSION_17,
2423
)
2524

25+
tasks.withType(JavaCompile) {
26+
options.errorprone.enabled = false
27+
}
28+
2629
description = "Apache Beam :: SDKs :: Java :: IO :: Delta Lake"
2730
ext.summary = "Integration with Delta Lake."
2831

32+
// We need to override the GCS bigdataos connector version to prevent conflicts.
33+
def bigdataoss_gcs_connector_version = "4.0.4"
34+
35+
def parquet_version = "1.16.0"
2936

3037
dependencies {
3138
implementation project(path: ":sdks:java:core", configuration: "shadow")
@@ -35,5 +42,45 @@ dependencies {
3542
permitUnusedDeclared library.java.delta_kernel_api
3643
permitUnusedDeclared library.java.delta_kernel_defaults
3744

45+
implementation library.java.hadoop_common
46+
implementation library.java.joda_time
47+
implementation library.java.slf4j_api
48+
implementation "org.apache.parquet:parquet-column:$parquet_version"
49+
implementation "org.apache.parquet:parquet-hadoop:$parquet_version"
50+
51+
// We need to override the GCS connector version to prevent conflicts with
52+
// latest Hadoop.
53+
implementation "com.google.cloud.bigdataoss:gcs-connector:$bigdataoss_gcs_connector_version"
54+
implementation "com.google.cloud.bigdataoss:util-hadoop:$bigdataoss_gcs_connector_version"
55+
implementation "com.google.cloud.bigdataoss:gcsio:$bigdataoss_gcs_connector_version"
56+
implementation "com.google.cloud.bigdataoss:util:$bigdataoss_gcs_connector_version"
57+
permitUnusedDeclared "com.google.cloud.bigdataoss:gcs-connector:$bigdataoss_gcs_connector_version"
58+
permitUnusedDeclared "com.google.cloud.bigdataoss:util-hadoop:$bigdataoss_gcs_connector_version"
59+
permitUnusedDeclared "com.google.cloud.bigdataoss:gcsio:$bigdataoss_gcs_connector_version"
60+
permitUnusedDeclared "com.google.cloud.bigdataoss:util:$bigdataoss_gcs_connector_version"
61+
62+
// For Avro conversions
63+
testImplementation project(":sdks:java:extensions:avro")
64+
65+
testImplementation library.java.avro
3866
testImplementation library.java.junit
67+
testImplementation library.java.hamcrest
68+
testImplementation "org.apache.parquet:parquet-avro:$parquet_version"
69+
testImplementation project(":sdks:java:io:parquet")
70+
testImplementation project(":sdks:java:managed")
71+
testRuntimeOnly "org.yaml:snakeyaml:2.0"
72+
testImplementation project(path: ":runners:direct-java", configuration: "shadow")
73+
}
74+
75+
configurations.all {
76+
// Exclude conflicting logging frameworks
77+
exclude group: "org.apache.logging.log4j", module: "log4j-slf4j2-impl"
78+
exclude group: "org.apache.logging.log4j", module: "log4j-slf4j-impl"
79+
exclude group: "org.slf4j", module: "slf4j-reload4j"
80+
81+
// Force overriding for all configurations
82+
resolutionStrategy.force "com.google.cloud.bigdataoss:gcs-connector:$bigdataoss_gcs_connector_version"
83+
resolutionStrategy.force "com.google.cloud.bigdataoss:util-hadoop:$bigdataoss_gcs_connector_version"
84+
resolutionStrategy.force "com.google.cloud.bigdataoss:gcsio:$bigdataoss_gcs_connector_version"
85+
resolutionStrategy.force "com.google.cloud.bigdataoss:util:$bigdataoss_gcs_connector_version"
3986
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.beam.sdk.io.delta;
19+
20+
import io.delta.kernel.engine.Engine;
21+
import io.delta.kernel.engine.ExpressionHandler;
22+
import io.delta.kernel.engine.FileSystemClient;
23+
import io.delta.kernel.engine.JsonHandler;
24+
import io.delta.kernel.engine.ParquetHandler;
25+
26+
/** A Beam specific {@link Engine} wrapper that provides a custom {@link ParquetHandler}. */
27+
public class BeamEngine implements Engine {
28+
private final Engine delegate;
29+
private final ParquetHandler parquetHandler;
30+
31+
public BeamEngine(Engine delegate, ParquetHandler parquetHandler) {
32+
this.delegate = delegate;
33+
this.parquetHandler = parquetHandler;
34+
}
35+
36+
@Override
37+
public ExpressionHandler getExpressionHandler() {
38+
return delegate.getExpressionHandler();
39+
}
40+
41+
@Override
42+
public JsonHandler getJsonHandler() {
43+
return delegate.getJsonHandler();
44+
}
45+
46+
@Override
47+
public FileSystemClient getFileSystemClient() {
48+
return delegate.getFileSystemClient();
49+
}
50+
51+
@Override
52+
public ParquetHandler getParquetHandler() {
53+
return parquetHandler;
54+
}
55+
}

0 commit comments

Comments
 (0)