yuqi1129 commented on code in PR #9821:
URL: https://github.com/apache/gravitino/pull/9821#discussion_r2757522340


##########
catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/operation/JdbcTableOperations.java:
##########
@@ -95,6 +100,87 @@ public void initialize(
     this.columnDefaultValueConverter = jdbcColumnDefaultValueConverter;
   }
 
+  /**
+   * Handles quoting for default values based on the column data type. For 
example, if the default
+   * valur is ""(empty string), it will be represented as two single quotes '' 
for string-like
+   * columns, or NULL for others.
+   *
+   * @param column the column
+   * @param defaultValueExpression the default value expression
+   * @return the properly quoted default value as a string
+   */
+  protected String handleQuotingForDefaultValue(
+      JdbcColumn column, Expression defaultValueExpression) {
+    String defaultValue = 
columnDefaultValueConverter.fromGravitino(defaultValueExpression);
+
+    // Special handling for SQL NULL: do not quote it, even for string-like 
columns.
+    if (Literals.NULL.equals(defaultValueExpression)) {
+      return "NULL";
+    }
+
+    // Special handling for string-like columns.
+    if (column.dataType() instanceof VarCharType
+        || column.dataType() instanceof StringType
+        || column.dataType() instanceof FixedCharType) {
+      if (StringUtils.isEmpty(defaultValue)) {
+        // Represent empty string default as two single quotes.
+        return "''";
+      }
+
+      // If the converter already produced a quoted literal, preserve it.

Review Comment:
   Please see L74
   
https://github.com/apache/gravitino/blob/b5af4dc09db75557d0a1a874bda91b8ddc77bc5b/catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/converter/JdbcColumnDefaultValueConverter.java#L58-L76



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