-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](iceberg) Support nested decimal precision promotion #65122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,9 @@ | |
| import org.apache.doris.catalog.ArrayType; | ||
| import org.apache.doris.catalog.Column; | ||
| import org.apache.doris.catalog.MapType; | ||
| import org.apache.doris.catalog.ScalarType; | ||
| import org.apache.doris.catalog.StructField; | ||
| import org.apache.doris.catalog.StructType; | ||
| import org.apache.doris.catalog.Type; | ||
| import org.apache.doris.common.UserException; | ||
| import org.apache.doris.common.security.authentication.ExecutionAuthenticator; | ||
|
|
@@ -103,6 +106,38 @@ public void testValidateForModifyComplexColumnRejectsIncompatibleNestedType() { | |
| "Cannot change int to smallint in nested types"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testValidateForModifyComplexColumnAllowsNestedDecimalPrecisionPromotion() throws Throwable { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still only exercises the new decimal promotion through a struct field. The production path this PR enables is recursive for all complex shapes, and after validation |
||
| Column column = new Column("struct_col", | ||
| new StructType(new StructField("d", ScalarType.createDecimalV3Type(10, 3))), true); | ||
| NestedField currentCol = Types.NestedField.required(1, "struct_col", | ||
| Types.StructType.of(Types.NestedField.optional(2, "d", | ||
| Types.DecimalType.of(5, 3)))); | ||
| invokeValidateForModifyComplexColumn(column, currentCol); | ||
| } | ||
|
|
||
| @Test | ||
| public void testValidateForModifyComplexColumnRejectsNestedDecimalPrecisionNarrowing() { | ||
| Column column = new Column("struct_col", | ||
| new StructType(new StructField("d", ScalarType.createDecimalV3Type(5, 3))), true); | ||
| NestedField currentCol = Types.NestedField.required(1, "struct_col", | ||
| Types.StructType.of(Types.NestedField.optional(2, "d", | ||
| Types.DecimalType.of(10, 3)))); | ||
| assertUserException(() -> invokeValidateForModifyComplexColumn(column, currentCol), | ||
| "Cannot change decimalv3(10,3) to decimalv3(5,3) in nested types"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testValidateForModifyComplexColumnRejectsNestedDecimalScaleChange() { | ||
| Column column = new Column("struct_col", | ||
| new StructType(new StructField("d", ScalarType.createDecimalV3Type(10, 4))), true); | ||
| NestedField currentCol = Types.NestedField.required(1, "struct_col", | ||
| Types.StructType.of(Types.NestedField.optional(2, "d", | ||
| Types.DecimalType.of(5, 3)))); | ||
| assertUserException(() -> invokeValidateForModifyComplexColumn(column, currentCol), | ||
| "Cannot change decimalv3(5,3) to decimalv3(10,4) in nested types"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testValidateForModifyComplexColumnRejectsPrimitiveToComplex() { | ||
| Column column = new Column("arr_i", ArrayType.create(Type.INT, true), true); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.