mrhhsg commented on code in PR #63528:
URL: https://github.com/apache/doris/pull/63528#discussion_r4227166098
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java:
##########
@@ -630,16 +629,68 @@ private void validateInternal(boolean isOlap, Set<String>
keysSet, Set<String> c
* Validate non-null defaults for complex types before connector-specific
validation.
*/
public void validateComplexTypeDefaultValue() throws AnalysisException {
- if (!defaultValue.isPresent() || defaultValue.get() ==
DefaultValue.NULL_DEFAULT_VALUE) {
- return;
- }
- if (type.isMapType()) {
- throw new AnalysisException("Map type column default value just
support null");
+ if (type.isArrayType()) {
+ validateArrayDefaultValue();
+ } else if (type.isMapType()) {
+ validateMapDefaultValue();
} else if (type.isStructType()) {
- throw new AnalysisException("Struct type column default value just
support null");
+ validateStructDefaultValue();
} else if (type.isJsonType() || type.isVariantType()) {
- throw new AnalysisException("Json or Variant type column default
value just support null");
+ if (hasNonNullDefaultValue()) {
+ throw new AnalysisException("Json or Variant type column
default value only supports DEFAULT NULL");
+ }
+ }
+ }
+
+ private void validateArrayDefaultValue() {
+ if (!hasNonNullDefaultValue()) {
+ return;
}
+ if (!isLiteralDefaultValue(ArrayLiteral.class)) {
+ throw new AnalysisException("Array type column default value only
supports array literals or DEFAULT NULL");
+ }
+ }
+
+ private void validateMapDefaultValue() {
+ if (!hasNonNullDefaultValue()) {
+ return;
+ }
+ if (!isLiteralDefaultValue(MapLiteral.class)) {
Review Comment:
Addressed in f44cc1901ac. `NereidsDataDescription` now routes
`default_value` and `replace_value` validation through `validateColumnValue`,
which validates complex columns with `ComplexTypeDefaultValue.canonicalize` and
keeps `ColumnDef.validateDefaultValue` for scalar columns, so the one-argument
`replace_value(null)` fallback no longer hits the scalar-only precondition.
Covered by the stream load case `replace_value` in `test_complex_default_value`
(`columns: k, v, v = replace_value(null)` on `MAP<STRING, INT> DEFAULT '{"a":
1}'`).
--
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]