Skip to content

Commit

Permalink
[Fix][API] Fix column length can not be long (#8039)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hisoka-X authored Nov 14, 2024
1 parent 24d0542 commit 16cf632
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,12 @@ public List<Column> parse(ReadonlyConfig schemaConfig) {
new IllegalArgumentException(
"schema.columns.* config need option [type], please correct your config first"));

Integer columnLength =
Long columnLength =
columnConfig.get(
TableSchemaOptions.ColumnOptions.COLUMN_LENGTH);

Integer columnScale =
columnConfig.get(
TableSchemaOptions.ColumnOptions.COLUMN_SCALE);

Boolean nullable =
columnConfig.get(TableSchemaOptions.ColumnOptions.NULLABLE);
Object defaultValue =
Expand All @@ -149,7 +147,7 @@ public List<Column> parse(ReadonlyConfig schemaConfig) {
return PhysicalColumn.of(
name,
seaTunnelDataType,
Long.valueOf(columnLength),
columnLength,
columnScale,
nullable,
defaultValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public static class ColumnOptions {
.noDefaultValue()
.withDescription("SeaTunnel Schema Column scale");

public static final Option<Integer> COLUMN_LENGTH =
public static final Option<Long> COLUMN_LENGTH =
Options.key("columnLength")
.intType()
.defaultValue(0)
.longType()
.defaultValue(0L)
.withDescription("SeaTunnel Schema Column Length");

public static final Option<Boolean> NULLABLE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void assertConstraintKey(TableSchema tableSchema) {
constraintKey.getColumnNames().get(0).getSortType());
}

private void assertColumn(TableSchema tableSchema, boolean checkDefaultValue) {
private void assertColumn(TableSchema tableSchema, boolean comeFromColumnConfig) {
List<Column> columns = tableSchema.getColumns();
Assertions.assertEquals(19, columns.size());

Expand Down Expand Up @@ -109,12 +109,13 @@ private void assertColumn(TableSchema tableSchema, boolean checkDefaultValue) {
SeaTunnelRowType seatunnalRowType1 = (SeaTunnelRowType) seaTunnelRowType.getFieldType(17);
Assertions.assertEquals(17, seatunnalRowType1.getTotalFields());

if (checkDefaultValue) {
if (comeFromColumnConfig) {
Assertions.assertEquals(0, columns.get(0).getDefaultValue());
Assertions.assertEquals("I'm default value", columns.get(4).getDefaultValue());
Assertions.assertEquals(false, columns.get(5).getDefaultValue());
Assertions.assertEquals(1.1, columns.get(10).getDefaultValue());
Assertions.assertEquals("2020-01-01", columns.get(15).getDefaultValue());
Assertions.assertEquals(4294967295L, columns.get(4).getColumnLength());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ schema = {
type = "string"
nullable = true
defaultValue = "I'm default value"
// bigger than integer max value
columnLength = 4294967295
comment = "string value"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private Optional<AssertCatalogTableRule.AssertColumnRule> parseColumnRule(
config -> {
String name = config.getString(COLUMN_NAME);
String type = config.getString(COLUMN_TYPE);
Integer columnLength =
Long columnLength =
TypesafeConfigUtils.getConfig(
config,
COLUMN_LENGTH,
Expand Down

0 comments on commit 16cf632

Please sign in to comment.