mchades commented on code in PR #14659:
URL: https://github.com/apache/gravitino/pull/14659#discussion_r4500372811


##########
common/src/main/java/org/apache/gravitino/dto/util/DTOConverters.java:
##########
@@ -1651,4 +1673,46 @@ public static PolicyContent fromDTO(PolicyContentDTO 
policyContentDTO) {
     throw new IllegalArgumentException(
         "Unsupported policy content type: " + policyContentDTO.getClass());
   }
+
+  private static boolean isBinaryOrFixed(Type dataType) {
+    return dataType instanceof Types.BinaryType || dataType instanceof 
Types.FixedType;
+  }
+
+  private static String literalValueToDtoString(Object value, Type dataType) {
+    // byte[].toString() is an object identity and cannot preserve the 
literal's bytes.
+    if (isBinaryOrFixed(dataType) && value instanceof byte[]) {
+      return BINARY_HEX_PREFIX + BINARY_HEX.encode((byte[]) value);
+    }
+    return value.toString();
+  }
+
+  /**
+   * Decodes {@code 0x}-prefixed hex for binary/fixed. Unprefixed values keep 
their previous string
+   * interpretation (#14609).
+   */
+  private static Object literalValueFromDtoString(String value, Type dataType) 
{
+    if (!isBinaryOrFixed(dataType) || value == null) {
+      return value;

Review Comment:
   [P2] The new rejection breaks the existing binary wire contract. [The 
expression 
guide](https://github.com/apache/gravitino/blob/694248108976e6409a864ff9fa046bdd8453bb5b/docs/expression.md#L50-L55)
 explicitly preserves unprefixed binary strings for provider-specific 
interpretation. I reproduced a binary default with `value: "AB"` through 
`ColumnDTO` → `DTOConverters.fromDTO()` → PostgreSQL's default converter: base 
`942e5d6` renders `DEFAULT 'AB'`, while `6942481` throws 
`IllegalArgumentException` before reaching the provider. `0x4142` works on 
both. Please retain the unprefixed compatibility path in the shared decoder and 
add a regression test; the Iceberg read path can keep emitting `0x`-prefixed 
values.



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