diqiu50 commented on code in PR #10318:
URL: https://github.com/apache/gravitino/pull/10318#discussion_r2965808058
##########
catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseColumnDefaultValueConverter.java:
##########
@@ -57,10 +58,19 @@ public String fromGravitino(Expression defaultValue) {
return literal.value().toString();
} else {
Object value = literal.value();
+ Preconditions.checkArgument(
+ value != null, "Null default literal value is not supported for
ClickHouse.");
if (value instanceof LocalDateTime) {
value = ((LocalDateTime) value).format(DATE_TIME_FORMATTER);
+ } else if (value instanceof String str
+ && str.length() >= 2
+ && str.startsWith("'")
+ && str.endsWith("'")) {
+ // The API caller may pass quoted string literals (e.g. "'active'"),
but DDL generation
+ // is responsible for adding the outer quotes.
Review Comment:
if the `value` = "'active'", that means the const value is "'active'",
right? should pass to '''a''' to the DDL
##########
catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseColumnDefaultValueConverter.java:
##########
@@ -57,10 +58,19 @@ public String fromGravitino(Expression defaultValue) {
return literal.value().toString();
} else {
Object value = literal.value();
+ Preconditions.checkArgument(
+ value != null, "Null default literal value is not supported for
ClickHouse.");
if (value instanceof LocalDateTime) {
value = ((LocalDateTime) value).format(DATE_TIME_FORMATTER);
+ } else if (value instanceof String str
+ && str.length() >= 2
+ && str.startsWith("'")
+ && str.endsWith("'")) {
+ // The API caller may pass quoted string literals (e.g. "'active'"),
but DDL generation
+ // is responsible for adding the outer quotes.
+ value = str.substring(1, str.length() - 1).replace("''", "'");
}
- return String.format("'%s'", value);
+ return String.format("'%s'", value.toString().replace("'", "''"));
Review Comment:
Can you extract functions to handle quote string and unquote string
--
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]