flyrain commented on code in PR #4539: URL: https://github.com/apache/iceberg/pull/4539#discussion_r856672352
########## spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/actions/BaseGetChangeSetSparkAction.java: ########## @@ -0,0 +1,282 @@ +/* + * 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.iceberg.spark.actions; + +import java.util.List; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import org.apache.iceberg.BaseFileScanTask; +import org.apache.iceberg.DataFile; +import org.apache.iceberg.DataOperations; +import org.apache.iceberg.FileContent; +import org.apache.iceberg.FileScanTask; +import org.apache.iceberg.HasTableOperations; +import org.apache.iceberg.ManifestFile; +import org.apache.iceberg.ManifestGroup; +import org.apache.iceberg.MetadataColumns; +import org.apache.iceberg.Snapshot; +import org.apache.iceberg.Table; +import org.apache.iceberg.actions.GetChangeSet; +import org.apache.iceberg.expressions.Expression; +import org.apache.iceberg.expressions.Expressions; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList; +import org.apache.iceberg.relocated.com.google.common.collect.Lists; +import org.apache.iceberg.relocated.com.google.common.collect.Sets; +import org.apache.iceberg.spark.FileScanTaskSetManager; +import org.apache.iceberg.spark.SparkReadOptions; +import org.apache.iceberg.util.SnapshotUtil; +import org.apache.spark.sql.Dataset; +import org.apache.spark.sql.Row; +import org.apache.spark.sql.SparkSession; +import org.apache.spark.sql.functions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.spark.sql.functions.lit; + +public class BaseGetChangeSetSparkAction extends BaseSparkAction<GetChangeSet, GetChangeSet.Result> + implements GetChangeSet { + private static final Logger LOG = LoggerFactory.getLogger(BaseGetChangeSetSparkAction.class); + public static final String RECORD_TYPE = "_record_type"; + public static final String COMMIT_SNAPSHOT_ID = "_commit_snapshot_id"; + public static final String COMMIT_TIMESTAMP = "_commit_timestamp"; + public static final String COMMIT_ORDER = "_commit_order"; + + private final List<Long> snapshotIds = Lists.newLinkedList(); Review Comment: We should consider them incompatible, right? For example, if you do ``` getChangeSet(table).betweenSnapshots(s1, s2).forCurrentSnapshot(s3).execute() ``` It should only honor the later one, which is `forCurrentSnapshot(s3)`. If you flip the order like this ``` getChangeSet(table).forCurrentSnapshot(s3).betweenSnapshots(s1, s2).execute() ``` It should only pick up snapshots between s1 and s3. The current logic support this logic already. Basically, it cleans up the lists every time before adding any snapshot id into it. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
