chamikaramj commented on code in PR #32565: URL: https://github.com/apache/beam/pull/32565#discussion_r1779744920
########## sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/PortableIcebergDestinations.java: ########## @@ -0,0 +1,81 @@ +/* + * 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.io.iceberg; + +import java.util.List; +import org.apache.beam.sdk.schemas.Schema; +import org.apache.beam.sdk.util.RowFilter; +import org.apache.beam.sdk.util.RowStringInterpolator; +import org.apache.beam.sdk.values.Row; +import org.apache.beam.sdk.values.ValueInSingleWindow; +import org.apache.iceberg.FileFormat; +import org.apache.iceberg.catalog.TableIdentifier; +import org.checkerframework.checker.nullness.qual.Nullable; + +class PortableIcebergDestinations implements DynamicDestinations { + private final RowFilter rowFilter; + private final RowStringInterpolator interpolator; + private final String fileFormat; + + public PortableIcebergDestinations( + String destinationTemplate, + String fileFormat, + Schema inputSchema, + @Nullable List<String> fieldsToDrop, + @Nullable List<String> fieldsToKeep, + @Nullable String onlyField) { + interpolator = new RowStringInterpolator(destinationTemplate, inputSchema); + RowFilter rf = new RowFilter(inputSchema); + + if (fieldsToDrop != null) { Review Comment: Error out if more than one of these are set ? ########## sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/IcebergWriteSchemaTransformProvider.java: ########## @@ -160,7 +176,14 @@ public PCollectionRowTuple expand(PCollectionRowTuple input) { IcebergIO.WriteRows writeTransform = IcebergIO.writeRows(configuration.getIcebergCatalog()) - .to(TableIdentifier.parse(configuration.getTable())); + .to( + new PortableIcebergDestinations( Review Comment: Do we always expect the schema-transform to use "PortableIcebergDestinations" or will there be cases where we have to use the pass through (SingleTableDynamicDestinations) ? ########## sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/IcebergWriteSchemaTransformProvider.java: ########## @@ -89,6 +89,16 @@ public static Builder builder() { "For a streaming pipeline, sets the frequency at which snapshots are produced.") public abstract @Nullable Integer getTriggeringFrequencySeconds(); + @SchemaFieldDescription( + "A list of field names to keep in the input record. All other fields are dropped before writing.") Review Comment: We should clarify in the Javadocs that these are mutually exclusive and fail accordingly. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
