This is an automated email from the ASF dual-hosted git repository.

blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new a4f1619  HOTFIX: Fix partition constants (#918)
a4f1619 is described below

commit a4f16197851c758cb559a258d72deb81aa574557
Author: Ryan Blue <[email protected]>
AuthorDate: Sat Apr 11 13:36:58 2020 -0700

    HOTFIX: Fix partition constants (#918)
    
    Only identity partitions should be added to constants.
---
 api/src/main/java/org/apache/iceberg/transforms/Identity.java  | 5 +++++
 api/src/main/java/org/apache/iceberg/transforms/Transform.java | 9 +++++++++
 core/src/main/java/org/apache/iceberg/util/PartitionUtil.java  | 6 ++++--
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/api/src/main/java/org/apache/iceberg/transforms/Identity.java 
b/api/src/main/java/org/apache/iceberg/transforms/Identity.java
index 84bcce1..2e340d8 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Identity.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Identity.java
@@ -72,6 +72,11 @@ class Identity<T> implements Transform<T, T> {
   }
 
   @Override
+  public boolean isIdentity() {
+    return true;
+  }
+
+  @Override
   public String toHumanString(T value) {
     if (value == null) {
       return "null";
diff --git a/api/src/main/java/org/apache/iceberg/transforms/Transform.java 
b/api/src/main/java/org/apache/iceberg/transforms/Transform.java
index 6a7b837..ba0fb1b 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Transform.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Transform.java
@@ -83,6 +83,15 @@ public interface Transform<S, T> extends Serializable {
   UnboundPredicate<T> projectStrict(String name, BoundPredicate<S> predicate);
 
   /**
+   * Return whether this transform is the identity transform.
+   *
+   * @return true if this is an identity transform, false otherwise
+   */
+  default boolean isIdentity() {
+    return false;
+  }
+
+  /**
    * Returns a human-readable String representation of a transformed value.
    * <p>
    * null values will return "null"
diff --git a/core/src/main/java/org/apache/iceberg/util/PartitionUtil.java 
b/core/src/main/java/org/apache/iceberg/util/PartitionUtil.java
index 1ef67db..ce0d1f7 100644
--- a/core/src/main/java/org/apache/iceberg/util/PartitionUtil.java
+++ b/core/src/main/java/org/apache/iceberg/util/PartitionUtil.java
@@ -50,8 +50,10 @@ public class PartitionUtil {
     List<PartitionField> fields = spec.fields();
     for (int pos = 0; pos < fields.size(); pos += 1) {
       PartitionField field = fields.get(pos);
-      Object converted = 
convertConstant.apply(partitionFields.get(pos).type(), partitionData.get(pos, 
Object.class));
-      idToConstant.put(field.sourceId(), converted);
+      if (field.transform().isIdentity()) {
+        Object converted = 
convertConstant.apply(partitionFields.get(pos).type(), partitionData.get(pos, 
Object.class));
+        idToConstant.put(field.sourceId(), converted);
+      }
     }
     return idToConstant;
   }

Reply via email to