the-other-tim-brown commented on code in PR #14312:
URL: https://github.com/apache/hudi/pull/14312#discussion_r2557285733


##########
hudi-common/src/main/java/org/apache/hudi/common/schema/HoodieSchema.java:
##########
@@ -931,4 +1062,204 @@ public HoodieSchema build() {
       return new HoodieSchema(avroSchema);
     }
   }
+
+  public static class Decimal extends HoodieSchema {
+    private final int precision;
+    private final int scale;
+    private final Option<Integer> fixedSize;
+
+    /**
+     * Creates a new HoodieSchema wrapping the given Avro schema.
+     *
+     * @param avroSchema the Avro schema to wrap, cannot be null
+     * @throws IllegalArgumentException if avroSchema is null or does not have 
a valid decimal logical type
+     */
+    private Decimal(Schema avroSchema) {
+      super(avroSchema);
+      LogicalType logicalType = avroSchema.getLogicalType();
+      if (!(logicalType instanceof LogicalTypes.Decimal)) {
+        throw new IllegalArgumentException("Decimal schema does not have a 
decimal logical type: " + avroSchema);
+      }
+      this.precision = ((LogicalTypes.Decimal) logicalType).getPrecision();
+      this.scale = ((LogicalTypes.Decimal) logicalType).getScale();
+      if (avroSchema.getType() == Schema.Type.FIXED) {
+        this.fixedSize = Option.of(avroSchema.getFixedSize());
+      } else {
+        this.fixedSize = Option.empty();
+      }
+    }
+
+    public int getPrecision() {
+      return precision;
+    }
+
+    public int getScale() {
+      return scale;
+    }
+
+    @Override
+    public Option<String> getName() {
+      return Option.of(String.format("decimal(%d,%d)", precision, scale));
+    }
+
+    @Override
+    public int getFixedSize() {
+      if (fixedSize.isPresent()) {
+        return fixedSize.get();
+      } else {
+        throw new IllegalStateException("Cannot get fixed size from non-fixed 
decimal schema");
+      }
+    }
+
+    @Override
+    public boolean equals(Object o) {
+      if (o == null || getClass() != o.getClass()) {
+        return false;
+      }
+      if (!super.equals(o)) {
+        return false;
+      }
+      Decimal decimal = (Decimal) o;
+      return precision == decimal.precision && scale == decimal.scale && 
Objects.equals(fixedSize, decimal.fixedSize);
+    }
+
+    @Override
+    public int hashCode() {
+      return Objects.hash(super.hashCode(), precision, scale, fixedSize);
+    }
+  }
+
+  public static class Timestamp extends HoodieSchema {
+    private final boolean isUtcAdjusted;
+    private final TimePrecision precision;

Review Comment:
   Yes, it is defined at the end of the class 
https://github.com/apache/hudi/pull/14312/files#diff-04bbd313fffea334e22a7a2ea4dd5b1c952e4fb771be6229d7bdf0923ba2eb08R1261



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to