rdblue commented on a change in pull request #1346: URL: https://github.com/apache/iceberg/pull/1346#discussion_r488106931
########## File path: flink/src/test/java/org/apache/iceberg/flink/source/TestFlinkInputFormat.java ########## @@ -0,0 +1,114 @@ +/* + * 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.flink.source; + +import java.io.IOException; +import java.util.List; +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.api.TableSchema; +import org.apache.flink.table.data.RowData; +import org.apache.flink.table.data.conversion.DataStructureConverter; +import org.apache.flink.table.data.conversion.DataStructureConverters; +import org.apache.flink.table.types.logical.RowType; +import org.apache.flink.table.types.utils.TypeConversions; +import org.apache.flink.types.Row; +import org.apache.iceberg.Schema; +import org.apache.iceberg.Table; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.iceberg.data.Record; +import org.apache.iceberg.expressions.Expression; +import org.apache.iceberg.flink.CatalogLoader; +import org.apache.iceberg.flink.FlinkSchemaUtil; +import org.apache.iceberg.flink.TableLoader; +import org.apache.iceberg.relocated.com.google.common.collect.Lists; + +/** + * Test {@link FlinkInputFormat}. + */ +public class TestFlinkInputFormat extends TestFlinkScan { + + private FlinkSource.Builder builder; + + public TestFlinkInputFormat(String fileFormat) { + super(fileFormat); + } + + @Override + public void before() throws IOException { + super.before(); + builder = FlinkSource.forBounded().tableLoader(TableLoader.fromHadoopTable(warehouse + "/default/t")); + } + + @Override + protected List<Row> executeWithOptions( + Table table, List<String> projectFields, CatalogLoader loader, Long snapshotId, Long startSnapshotId, + Long endSnapshotId, Long asOfTimestamp, List<Expression> filters, String sqlFilter) throws IOException { + ScanOptions options = ScanOptions.builder().snapshotId(snapshotId).startSnapshotId(startSnapshotId) + .endSnapshotId(endSnapshotId).asOfTimestamp(asOfTimestamp).build(); Review comment: I think the tests would be much more readable if the `ScanOptions` builder were used directly. For example, this is hard to understand: ```java assertRecords(executeWithOptions(table, null, null, null, snapshotId1, null, null, null, null), expected1, SCHEMA); ``` But you could rewrite that like this: ```java ScanOptions options = ScanOptions.builder().startSnapshotId(snapshotId1).build(); assertRecords(executeWithOptions(table, options), expected1, SCHEMA); ``` In addition, passing `null` into this leaks the default state within the builder into the tests: test authors need to know that passing `null` for `CatalogLoader` is supported. I think it is better to let the test authors use the builder pattern. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
