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


##########
common/src/main/java/org/apache/gravitino/dto/util/DTOConverters.java:
##########
@@ -1651,4 +1673,47 @@ 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 for provider-specific handling (#14609).
+   */
+  private static Object literalValueFromDtoString(String value, Type dataType) 
{
+    if (!isBinaryOrFixed(dataType) || value == null) {
+      return value;
+    }
+    if (!value.regionMatches(true, 0, BINARY_HEX_PREFIX, 0, 
BINARY_HEX_PREFIX.length())) {

Review Comment:
   Kept the shared `0x` decode: it matches the #14609 / `expression.md` wire 
contract (`0x` = hex bytes; unprefixed stays provider-specific), and JDBC 
already decoded `0x` the same way in `JdbcColumnDefaultValueConverter`.
   
   Added `testSharedDtoBinaryDecodeStillRendersJdbcSql` in `015e0d9ad`: DTO 
`0x4142` → JDBC `X'4142'`, unprefixed `AB` → `'AB'`.



##########
core/src/main/java/org/apache/gravitino/catalog/CapabilityHelpers.java:
##########
@@ -716,6 +718,7 @@ private static void applyColumnNotNull(
 
   private static void applyColumnDefaultValue(Column column, Capability 
capabilities) {
     applyColumnDefaultValue(column.name(), column.defaultValue(), 
capabilities);
+    applyColumnInitialDefaultValue(column.name(), 
column.initialDefaultValue());

Review Comment:
   Confirmed — `applyColumnInitialDefaultValue` only runs when applying a 
`Column` on create (and `AddColumn`, which has no initial-default field and 
therefore stays unset). Load does not go through this check; 
`UpdateColumnDefaultValue` only validates write-default capability.
   
   Added coverage in `015e0d9ad`: 
`testUpdateColumnDefaultValueDoesNotCheckInitialDefault` and 
`testAddColumnDoesNotCarryInitialDefault`. Load-then-create with a set initial 
default remains intentionally rejected 
(`testLoadThenCreateRejectsColumnsCarryingInitialDefault`).



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