github-actions[bot] commented on code in PR #63528:
URL: https://github.com/apache/doris/pull/63528#discussion_r4259284431
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java:
##########
@@ -628,20 +622,28 @@ private void validateInternal(boolean isOlap, Set<String>
keysSet, Set<String> c
/**
* Validate non-null defaults for complex types before connector-specific
validation.
+ * ARRAY, MAP and STRUCT defaults are rewritten into the canonical literal
text that BE parses.
*/
public void validateComplexTypeDefaultValue() throws AnalysisException {
- if (!defaultValue.isPresent() || defaultValue.get() ==
DefaultValue.NULL_DEFAULT_VALUE) {
+ if (!hasNonNullDefaultValue()) {
return;
}
- if (type.isMapType()) {
- throw new AnalysisException("Map type column default value just
support null");
- } else if (type.isStructType()) {
- throw new AnalysisException("Struct type column default value just
support null");
+ if (type.isArrayType() || type.isMapType() || type.isStructType()) {
+ defaultValue = Optional.of(new DefaultValue(
+ ComplexTypeDefaultValue.canonicalize(type,
defaultValue.get().getValue())));
Review Comment:
[P2] Preserve complex defaults in ALTER binlog SQL
With light schema change, `ALTER TABLE t ADD COLUMN m MAP<STRING,INT>
DEFAULT '{"a":1}'` now succeeds, but `ColumnDefinition.toSql()` still applies
`SqlUtils.escapeQuota` and emits `DEFAULT "{\"a\":1}"`.
`Alter.processAlterOlapTable` passes this text into
`TableAddOrDropColumnsInfo.rawSql`, and [CCR re-executes
it](https://github.com/selectdb/ccr-syncer/blob/6a76c231d42c5e012babe4c94eeefe765ac53fc8/pkg/ccr/base/spec.go#L1269-L1301).
The DDL parser only removes the outer quotes, so replay passes `{\"a\":1}` to
the canonicalizer and rejects it, stopping synchronization. Apply the
replay-safe quoting used by `Column.toSql()` to this ALTER serializer and cover
a serialized ADD COLUMN round trip. This is a separate consumer from the
already-fixed SHOW CREATE/LIKE thread.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]