You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/10/12 06:50:30 UTC

[GitHub] [iceberg] JingsongLi commented on a change in pull request #1517: Flink: apply row-level delete when reading

JingsongLi commented on a change in pull request #1517:
URL: https://github.com/apache/iceberg/pull/1517#discussion_r503072571



##########
File path: flink/src/test/java/org/apache/iceberg/flink/source/TestFlinkInputFormatReaderDeletes.java
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.Map;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.iceberg.BaseTable;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.TableMetadata;
+import org.apache.iceberg.TableOperations;
+import org.apache.iceberg.TableProperties;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.data.DeleteReadTests;
+import org.apache.iceberg.flink.CatalogLoader;
+import org.apache.iceberg.flink.FlinkSchemaUtil;
+import org.apache.iceberg.flink.RowDataWrapper;
+import org.apache.iceberg.flink.TableLoader;
+import org.apache.iceberg.flink.TestHelpers;
+import org.apache.iceberg.hive.HiveCatalog;
+import org.apache.iceberg.hive.TestHiveMetastore;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.util.StructLikeSet;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class TestFlinkInputFormatReaderDeletes extends DeleteReadTests {
+  private static HiveConf hiveConf = null;
+  private static HiveCatalog catalog = null;
+  private static TestHiveMetastore metastore = null;
+
+  private final FileFormat format;
+
+  @Parameterized.Parameters(name = "fileFormat={0}")
+  public static Object[][] parameters() {
+    return new Object[][] {
+        new Object[] { FileFormat.PARQUET },
+        new Object[] { FileFormat.AVRO },
+        new Object[] { FileFormat.ORC }
+    };
+  }
+
+  public TestFlinkInputFormatReaderDeletes(FileFormat inputFormat) {
+    this.format = inputFormat;
+  }
+
+  @BeforeClass
+  public static void startMetastore() {
+    TestFlinkInputFormatReaderDeletes.metastore = new TestHiveMetastore();
+    metastore.start();
+    TestFlinkInputFormatReaderDeletes.hiveConf = metastore.hiveConf();
+    TestFlinkInputFormatReaderDeletes.catalog = new HiveCatalog(hiveConf);
+  }
+
+  @AfterClass
+  public static void stopMetastore() {
+    metastore.stop();
+    catalog.close();
+    TestFlinkInputFormatReaderDeletes.catalog = null;
+  }
+
+  @Override
+  protected Table createTable(String name, Schema schema, PartitionSpec spec) {
+    Map<String, String> props = Maps.newHashMap();
+    props.put(TableProperties.DEFAULT_FILE_FORMAT, format.name());
+
+    Table table = catalog.createTable(TableIdentifier.of("default", name), schema, spec, props);
+    TableOperations ops = ((BaseTable) table).operations();
+    TableMetadata meta = ops.current();
+    ops.commit(meta, meta.upgradeToFormatVersion(2));
+
+    return table;
+  }
+
+  @Override
+  protected void dropTable(String name) {
+    catalog.dropTable(TableIdentifier.of("default", name));
+  }
+
+  @Override
+  protected StructLikeSet rowSet(String name, Table testTable, String... columns) throws IOException {
+    Schema projected = testTable.schema().select(columns);
+    RowType rowType = FlinkSchemaUtil.convert(projected);
+    CatalogLoader hiveCatalogLoader = CatalogLoader.hive(catalog.name(),

Review comment:
       Yes, but it is under refactor. https://github.com/apache/iceberg/pull/1565




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org