github-actions[bot] commented on code in PR #64026:
URL: https://github.com/apache/doris/pull/64026#discussion_r3342001439
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/InPartition.java:
##########
@@ -62,9 +61,15 @@ public AllPartitionDesc translateToCatalogStyle() {
// add a empty list for default value process
values.add(new ArrayList<>());
}
- List<List<PartitionValue>> catalogValues = values.stream().map(l ->
l.stream()
- .map(this::toLegacyPartitionValueStmt)
- .collect(Collectors.toList())).collect(Collectors.toList());
+ List<List<PartitionValue>> catalogValues = new ArrayList<>();
+ for (List<Expression> partitionExpressions : values) {
+ List<PartitionValue> partitionValues = new ArrayList<>();
+ for (int i = 0; i < partitionExpressions.size(); i++) {
+ partitionValues.add(
+
toLegacyPartitionValueStmt(partitionExpressions.get(i).castTo(partitionTypes.get(i))));
+ }
Review Comment:
This list-partition path now casts each tuple element with
`partitionTypes.get(i)` before any cardinality validation. For a single-column
LIST partition, input like `VALUES IN ((1, 2))` reaches this line with `i == 1`
and throws `IndexOutOfBoundsException` before the existing list partition size
check can report a controlled DDL error. Please validate every IN tuple size
against `partitionTypes` before casting, or otherwise preserve all values until
catalog validation can reject the malformed tuple.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMultiPartitionOp.java:
##########
@@ -117,12 +127,20 @@ private String getPartitionValuesStr(List<Expression>
values) {
return sb.toString();
}
- private PartitionValue toLegacyPartitionValue(Expression e) {
- if (e.isLiteral()) {
- return new PartitionValue(((Literal) e).getStringValue(),
e.isNullLiteral());
- } else if (e instanceof PartitionDefinition.MaxValue) {
+ private PartitionValue toLegacyPartitionValue(Expression
originalExpression, Expression typedExpression) {
+ if (typedExpression.isLiteral()) {
+ return new PartitionValue(((Literal)
typedExpression).toLegacyLiteral(), typedExpression.isNullLiteral(),
+ originalExpression.isNullLiteral() ? null : ((Literal)
originalExpression).getStringValue());
+ } else if (typedExpression instanceof PartitionDefinition.MaxValue) {
return PartitionValue.MAX_VALUE;
}
throw new AnalysisException("Unsupported partition value");
}
+
+ private Expression typedExpression(Expression expression, int index) {
+ if (partitionTypes == null) {
+ return expression;
+ }
+ return expression.castTo(partitionTypes.get(index));
+ }
Review Comment:
For `ALTER TABLE ... ADD PARTITIONS`, `partitionTypes` is populated from the
target table columns, but `typedExpression()` indexes it before validating the
`FROM`/`TO` value counts. A single-column table with `FROM (1, 2)` now fails
with `IndexOutOfBoundsException` at this line instead of a partition-boundary
validation error. Please check both boundary list sizes against
`partitionTypes.size()` before casting.
--
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]