Skip to content

Commit

Permalink
[FLINK-22640] [datagen] Fix DataGen SQL Connector does not support de…
Browse files Browse the repository at this point in the history
…fining fields min/max option of decimal type field

This closes apache#15900
  • Loading branch information
lincoln-lil authored May 13, 2021
1 parent 02d30ac commit e5435bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ public DataGeneratorContainer visit(DecimalType decimalType) {
return DataGeneratorContainer.of(
new DecimalDataRandomGenerator(
decimalType.getPrecision(), decimalType.getScale(),
config.get(min), config.get(max)));
config.get(min), config.get(max)),
min,
max);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ public void testDataTypeCoverage() throws Exception {
descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen");
descriptor.putString(NUMBER_OF_ROWS.key(), "10");

// add min max option for numeric types
descriptor.putString("fields.f4.min", "1.0");
descriptor.putString("fields.f4.max", "1000.0");
descriptor.putString("fields.f5.min", "0");
descriptor.putString("fields.f5.max", "127");
descriptor.putString("fields.f6.min", "0");
descriptor.putString("fields.f6.max", "32767");
descriptor.putString("fields.f7.min", "0");
descriptor.putString("fields.f7.max", "65535");
descriptor.putString("fields.f8.min", "0");
descriptor.putString("fields.f8.max", String.valueOf(Long.MAX_VALUE));
descriptor.putString("fields.f9.min", "0");
descriptor.putString("fields.f9.max", String.valueOf(Float.MAX_VALUE));
descriptor.putString("fields.f10.min", "0");
descriptor.putString("fields.f10.max", String.valueOf(Double.MAX_VALUE));

List<RowData> results = runGenerator(schema, descriptor);
Assert.assertEquals("Failed to generate all rows", 10, results.size());

Expand Down

0 comments on commit e5435bb

Please sign in to comment.