github-actions[bot] commented on code in PR #64026:
URL: https://github.com/apache/doris/pull/64026#discussion_r3351209652
##########
fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfoTest.java:
##########
@@ -287,4 +299,159 @@ public void testCheckPartitionNullity5() {
Assertions.assertThrows(AnalysisException.class, () ->
createTableInfo2.checkPartitionNullity(columnDefs2, partitionTableInfo2),
"Can't have null partition is for NOT NULL partition column in
partition expr's index 0");
}
+
+ @Test
+ public void
testLessThanPartitionRejectsExtraBoundaryValuesDuringTranslation() {
+ LessThanPartition lessThanPartition = new LessThanPartition(false,
"p1",
+ Lists.newArrayList(new StringLiteral("1"), new
StringLiteral("2")));
+
lessThanPartition.setPartitionTypes(Lists.newArrayList(IntegerType.INSTANCE));
+
+ AnalysisException exception =
Assertions.assertThrows(AnalysisException.class,
+ lessThanPartition::translateToCatalogStyle);
+ Assertions.assertTrue(exception.getMessage().contains(
+ "Partition values number is more than partition column
number"));
+ }
+
+ @Test
+ public void testInPartitionRejectsOversizedTupleDuringTranslation() {
+ List<Expression> tuple = new ArrayList<>();
+ tuple.add(new StringLiteral("1"));
+ tuple.add(new StringLiteral("2"));
+ List<List<Expression>> tuples = new ArrayList<>();
+ tuples.add(tuple);
+ InPartition inPartition = new InPartition(false, "p1",
+ tuples);
+
inPartition.setPartitionTypes(Lists.newArrayList(IntegerType.INSTANCE));
+
+ AnalysisException exception =
Assertions.assertThrows(AnalysisException.class,
+ inPartition::translateToCatalogStyle);
+ Assertions.assertTrue(exception.getMessage().contains(
+ "partition key desc list size[2] is not equal to partition
column size[1]"));
+ }
+
+ @Test
+ public void testInPartitionValidateWithoutPartitionTypesFailsFast() {
+ List<Expression> tuple = new ArrayList<>();
+ tuple.add(new StringLiteral("1"));
+ List<List<Expression>> tuples = new ArrayList<>();
+ tuples.add(tuple);
+ InPartition inPartition = new InPartition(false, "p1", tuples);
+
+ AnalysisException exception =
Assertions.assertThrows(AnalysisException.class,
+ () -> inPartition.validate(new HashMap<>()));
+ Assertions.assertTrue(exception.getMessage().contains(
+ "partitionTypes should be initialized before validating
partition definition"));
+ }
+
+ @Test
+ public void testInPartitionRejectsInvalidIntegerLiteralBeforeCasting() {
+ List<Expression> tuple = new ArrayList<>();
+ tuple.add(new StringLiteral("20.1"));
+ List<List<Expression>> tuples = new ArrayList<>();
+ tuples.add(tuple);
+ InPartition inPartition = new InPartition(false, "p1", tuples);
+
inPartition.setPartitionTypes(Lists.newArrayList(IntegerType.INSTANCE));
+
+ AnalysisException exception =
Assertions.assertThrows(AnalysisException.class,
+ inPartition::translateToCatalogStyle);
+ Assertions.assertTrue(exception.getMessage().contains("Invalid number
format: 20.1"));
+ }
+
+ @Test
+ public void testStepPartitionRejectsExtraBoundaryValuesBeforeCasting() {
+ StepPartition stepPartition = new StepPartition(false, "p1",
+ Lists.newArrayList(new StringLiteral("1"), new
StringLiteral("2")),
+ Lists.newArrayList(new StringLiteral("3"), new
StringLiteral("4")),
+ 1, "DAY");
+
stepPartition.setPartitionTypes(Lists.newArrayList(IntegerType.INSTANCE));
+
+ AnalysisException exception =
Assertions.assertThrows(AnalysisException.class,
+ stepPartition::translateToCatalogStyle);
+ Assertions.assertTrue(exception.getMessage().contains(
+ "partition column number in multi partition clause must be one
but start column size is 2, end column size is 2."));
+ }
+
+ @Test
+ public void
testAlterMultiPartitionRejectsExtraBoundaryValuesBeforeCasting() {
+ AlterMultiPartitionOp alterMultiPartitionOp = new
AlterMultiPartitionOp(
+ Lists.newArrayList(new StringLiteral("1"), new
StringLiteral("2")),
+ Lists.newArrayList(new StringLiteral("3"), new
StringLiteral("4")),
+ 1, "DAY", new HashMap<>(), false);
+
alterMultiPartitionOp.setPartitionTypes(Lists.newArrayList(IntegerType.INSTANCE));
+
+ AnalysisException exception =
Assertions.assertThrows(AnalysisException.class,
+ alterMultiPartitionOp::getPartitionKeyDesc);
+ Assertions.assertTrue(exception.getMessage().contains(
+ "partition column number in multi partition clause must be one
but start column size is 2, end column size is 2."));
+ }
+
+ @Test
+ public void
testAlterMultiPartitionRejectsInvalidIntegerLiteralBeforeCasting() {
+ AlterMultiPartitionOp alterMultiPartitionOp = new
AlterMultiPartitionOp(
+ Lists.newArrayList(new StringLiteral("20.1")),
+ Lists.newArrayList(new StringLiteral("21")),
+ 1, "DAY", new HashMap<>(), false);
+
alterMultiPartitionOp.setPartitionTypes(Lists.newArrayList(IntegerType.INSTANCE));
+
+ AnalysisException exception =
Assertions.assertThrows(AnalysisException.class,
+ alterMultiPartitionOp::getPartitionKeyDesc);
+ Assertions.assertTrue(exception.getMessage().contains("Invalid number
format: 20.1"));
+ }
+
Review Comment:
This method declaration is indented one level deeper than the surrounding
test methods, which should trip FE Checkstyle's indentation rule. Please align
it with the `@Test` annotation.
```suggestion
public void
testStepPartitionUsesCanonicalTimestampTzTextForMultiPartitionTranslation()
throws Exception {
```
--
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]