You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/03/03 22:18:13 UTC

[GitHub] [beam] laraschmidt commented on a change in pull request #16958: [BEAM-14020] Adding SchemaTransform, SchemaTransformProvider, and PCollectionRowTuple

laraschmidt commented on a change in pull request #16958:
URL: https://github.com/apache/beam/pull/16958#discussion_r819107672



##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollectionRowTuple.java
##########
@@ -0,0 +1,271 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.values;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * A {@link PCollectionRowTuple} is an immutable tuple of {@link PCollection PCollection<Row>s},
+ * "keyed" by a string tag. A {@link PCollectionRowTuple} can be used as the input or output of a
+ * {@link PTransform} taking or producing multiple {@code PCollection<Row>} inputs or outputs.
+ *
+ * <p>A {@link PCollectionRowTuple} can be created and accessed like follows:
+ *
+ * <pre>{@code
+ * PCollection<Row> pc1 = ...;
+ * PCollection<Row> pc2 = ...;
+ *
+ * // Create tags for each of the PCollections to put in the PCollectionTuple:
+ * String tag1 = "pc1";
+ * String tag2 = "pc2";
+ * String tag3 = "pc3";
+ *
+ * // Create a PCollectionTuple with three PCollections:
+ * PCollectionTuple pcs = PCollectionTuple.of(tag1, pc1).and(tag2, pc2).and(tag3, pc3);
+ *
+ * // Create an empty PCollectionTuple:
+ * Pipeline p = ...;
+ * PCollectionTuple pcs2 = PCollectionTuple.empty(p);

Review comment:
       Yeah I wanted that too, it seems like it should be easy to do. But I think unless we template the underlying class there's no real way to make this work. We could maybe make PCollectionTupleBase<T> and then Have PCollectionTuple extends Object and PCollectionRowTuple extend Row. But then we'd end up with Object instead of ?. I'm not actually sure how well that would work. Could give it a try but it still seems kind of messy.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org