You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "Fokko (via GitHub)" <gi...@apache.org> on 2023/05/25 15:11:44 UTC

[GitHub] [iceberg] Fokko commented on a diff in pull request #7685: Spark: Positional deletes creates partitioned path on unpartitioned tables

Fokko commented on code in PR #7685:
URL: https://github.com/apache/iceberg/pull/7685#discussion_r1205664366


##########
core/src/main/java/org/apache/iceberg/io/PartitionProjection.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.io;
+
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.StructLike;
+import org.apache.iceberg.types.Types;
+import org.apache.iceberg.util.StructProjection;
+
+public interface PartitionProjection extends StructLike {
+
+  PartitionProjection create(PartitionSpec spec, Types.StructType commonPartitionType);
+
+  PartitionProjection wrap(StructLike newStruct);
+
+  static PartitionProjection of(PartitionSpec spec, Types.StructType commonPartitionType) {
+    if (spec.isUnpartitioned()) {
+      return UnpartitionedSpecProjection.INSTANCE;
+    } else {
+      return new PartitionedSpecProjection().create(spec, commonPartitionType);
+    }
+  }
+
+  class UnpartitionedSpecProjection implements PartitionProjection {
+    static final PartitionProjection INSTANCE = new UnpartitionedSpecProjection();
+
+    @Override
+    public PartitionProjection create(PartitionSpec spec, Types.StructType commonPartitionType) {
+      return this;
+    }
+
+    @Override
+    public PartitionProjection wrap(StructLike newStruct) {
+      return null;

Review Comment:
   @stevenzwu that's similar to what I had before: https://github.com/apache/iceberg/pull/7685/commits/ca63c4b47d52935b4d60103e1f5e514fe1a5a254
   
   I think we expect the struct to be `null` when there is not partition. It looks like this is expected in many parts of the code. I'm fine either way, but I'd love to get the opinion of @rdblue or @aokolnychyi 



-- 
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: issues-unsubscribe@iceberg.apache.org

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