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 2019/06/06 06:09:08 UTC

[GitHub] [incubator-iceberg] rdsr commented on a change in pull request #207: Add external schema mappings for files written with name-based schemas #40

rdsr commented on a change in pull request #207: Add external schema mappings for files written with name-based schemas #40
URL: https://github.com/apache/incubator-iceberg/pull/207#discussion_r291031570
 
 

 ##########
 File path: core/src/test/java/org/apache/iceberg/avro/TestExtNameToFieldIdsMap.java
 ##########
 @@ -0,0 +1,118 @@
+/*
+ * 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.avro;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import org.apache.avro.file.DataFileWriter;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericDatumWriter;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.iceberg.Files;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.types.TypeUtil;
+import org.junit.Assert;
+
+public class TestExtNameToFieldIdsMap extends TestReadProjection {
+  private static final Splitter DOT = Splitter.on(".");
+
+  @Override
+  protected GenericData.Record writeAndRead(String desc,
+                                            Schema writeSchema,
+                                            Schema readSchema,
+                                            GenericData.Record record) throws IOException {
+
+    // We should get this external mapping from table properties, but for now
+    // I'm building this using the combination of read and write schemas
+    // I'm happy to change this based on comments.
+    // I'm also unsure on the direction we want to proceed with tests so
+    // for now, I've supporting the existing read projection tests
+    Map<String, Integer> namesToId = fieldNameToIds(readSchema, writeSchema);
 
 Review comment:
   This is mostly a hack, would appreciate better ways to address this.

----------------------------------------------------------------
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


With regards,
Apache Git Services

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