Skip to content

Commit a83754a

Browse files
authored
Implements the Delta Lake source with support for splitting (#38706)
1 parent 7916452 commit a83754a

12 files changed

Lines changed: 3125 additions & 4 deletions

File tree

sdks/java/io/delta/build.gradle

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ applyJavaNature(
2626
description = "Apache Beam :: SDKs :: Java :: IO :: Delta Lake"
2727
ext.summary = "Integration with Delta Lake."
2828

29+
// We need to override the GCS bigdataos connector version to prevent conflicts.
30+
def bigdataoss_gcs_connector_version = "4.0.4"
31+
32+
def parquet_version = "1.16.0"
2933

3034
dependencies {
3135
implementation project(path: ":sdks:java:core", configuration: "shadow")
@@ -35,5 +39,45 @@ dependencies {
3539
permitUnusedDeclared library.java.delta_kernel_api
3640
permitUnusedDeclared library.java.delta_kernel_defaults
3741

42+
implementation library.java.hadoop_common
43+
implementation library.java.joda_time
44+
// implementation library.java.slf4j_api
45+
implementation "org.apache.parquet:parquet-column:$parquet_version"
46+
implementation "org.apache.parquet:parquet-hadoop:$parquet_version"
47+
48+
// We need to override the GCS connector version to prevent conflicts with
49+
// latest Hadoop.
50+
implementation "com.google.cloud.bigdataoss:gcs-connector:$bigdataoss_gcs_connector_version"
51+
implementation "com.google.cloud.bigdataoss:util-hadoop:$bigdataoss_gcs_connector_version"
52+
implementation "com.google.cloud.bigdataoss:gcsio:$bigdataoss_gcs_connector_version"
53+
implementation "com.google.cloud.bigdataoss:util:$bigdataoss_gcs_connector_version"
54+
permitUnusedDeclared "com.google.cloud.bigdataoss:gcs-connector:$bigdataoss_gcs_connector_version"
55+
permitUnusedDeclared "com.google.cloud.bigdataoss:util-hadoop:$bigdataoss_gcs_connector_version"
56+
permitUnusedDeclared "com.google.cloud.bigdataoss:gcsio:$bigdataoss_gcs_connector_version"
57+
permitUnusedDeclared "com.google.cloud.bigdataoss:util:$bigdataoss_gcs_connector_version"
58+
59+
// For Avro conversions
60+
testImplementation project(":sdks:java:extensions:avro")
61+
62+
testImplementation library.java.avro
3863
testImplementation library.java.junit
64+
testImplementation library.java.hamcrest
65+
testImplementation "org.apache.parquet:parquet-avro:$parquet_version"
66+
testImplementation project(":sdks:java:io:parquet")
67+
testImplementation project(":sdks:java:managed")
68+
testRuntimeOnly "org.yaml:snakeyaml:2.0"
69+
testImplementation project(path: ":runners:direct-java", configuration: "shadow")
70+
}
71+
72+
configurations.all {
73+
// Exclude conflicting logging frameworks
74+
exclude group: "org.apache.logging.log4j", module: "log4j-slf4j2-impl"
75+
exclude group: "org.apache.logging.log4j", module: "log4j-slf4j-impl"
76+
exclude group: "org.slf4j", module: "slf4j-reload4j"
77+
78+
// Force overriding for all configurations
79+
resolutionStrategy.force "com.google.cloud.bigdataoss:gcs-connector:$bigdataoss_gcs_connector_version"
80+
resolutionStrategy.force "com.google.cloud.bigdataoss:util-hadoop:$bigdataoss_gcs_connector_version"
81+
resolutionStrategy.force "com.google.cloud.bigdataoss:gcsio:$bigdataoss_gcs_connector_version"
82+
resolutionStrategy.force "com.google.cloud.bigdataoss:util:$bigdataoss_gcs_connector_version"
3983
}
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)