|
| 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 com.google.auto.value.AutoValue; |
| 21 | +import java.util.Map; |
| 22 | +import org.apache.beam.sdk.annotations.Internal; |
| 23 | +import org.apache.beam.sdk.transforms.PTransform; |
| 24 | +import org.apache.beam.sdk.values.PBegin; |
| 25 | +import org.apache.beam.sdk.values.PCollection; |
| 26 | +import org.apache.beam.sdk.values.Row; |
| 27 | +import org.checkerframework.checker.nullness.qual.Nullable; |
| 28 | + |
| 29 | +/** |
| 30 | + * A connector that reads from <a href="https://delta.io/">Delta Lake</a> tables. |
| 31 | + * |
| 32 | + * <p>This is work in progress. For more details and to track progress, please see <a |
| 33 | + * href="https://github.com/apache/beam/issues/21100">Issue 21100</a>. |
| 34 | + */ |
| 35 | +@Internal |
| 36 | +public class DeltaIO { |
| 37 | + |
| 38 | + public static ReadRows readRows() { |
| 39 | + return new AutoValue_DeltaIO_ReadRows.Builder().build(); |
| 40 | + } |
| 41 | + |
| 42 | + @AutoValue |
| 43 | + public abstract static class ReadRows extends PTransform<PBegin, PCollection<Row>> { |
| 44 | + |
| 45 | + public abstract @Nullable String getTablePath(); |
| 46 | + |
| 47 | + public abstract @Nullable Long getVersion(); |
| 48 | + |
| 49 | + public abstract @Nullable String getTimestamp(); |
| 50 | + |
| 51 | + public abstract @Nullable Map<String, String> getHadoopConfig(); |
| 52 | + |
| 53 | + abstract Builder toBuilder(); |
| 54 | + |
| 55 | + @AutoValue.Builder |
| 56 | + abstract static class Builder { |
| 57 | + abstract Builder setTablePath(String tablePath); |
| 58 | + |
| 59 | + abstract Builder setVersion(@Nullable Long version); |
| 60 | + |
| 61 | + abstract Builder setTimestamp(@Nullable String timestamp); |
| 62 | + |
| 63 | + abstract Builder setHadoopConfig(@Nullable Map<String, String> hadoopConfig); |
| 64 | + |
| 65 | + abstract ReadRows build(); |
| 66 | + } |
| 67 | + |
| 68 | + public ReadRows from(String tablePath) { |
| 69 | + return toBuilder().setTablePath(tablePath).build(); |
| 70 | + } |
| 71 | + |
| 72 | + public ReadRows withVersion(@Nullable Long version) { |
| 73 | + return toBuilder().setVersion(version).build(); |
| 74 | + } |
| 75 | + |
| 76 | + public ReadRows withTimestamp(@Nullable String timestamp) { |
| 77 | + return toBuilder().setTimestamp(timestamp).build(); |
| 78 | + } |
| 79 | + |
| 80 | + public ReadRows withConfig(Map<String, String> config) { |
| 81 | + return toBuilder().setHadoopConfig(config).build(); |
| 82 | + } |
| 83 | + |
| 84 | + @Override |
| 85 | + public PCollection<Row> expand(PBegin input) { |
| 86 | + // TODO(https://github.com/apache/beam/issues/38551): Implement expansion for |
| 87 | + // Delta Lake ReadRows |
| 88 | + throw new UnsupportedOperationException("Not implemented yet."); |
| 89 | + } |
| 90 | + } |
| 91 | +} |
0 commit comments