NIFI-11590: Missing Enum data type handling in FlowFileTable

This closes #7294.

Signed-off-by: Peter Turcsanyi <turcsanyi@apache.org>
This commit is contained in:
Mark Bathori 2023-05-25 14:41:42 +02:00 committed by Peter Turcsanyi
parent de62c6261f
commit cfd62c9511
No known key found for this signature in database
GPG Key ID: 55A813F1C3E553DC
2 changed files with 13 additions and 1 deletions

View File

@ -227,6 +227,8 @@ public class FlowFileTable extends AbstractTable implements QueryableTable, Tran
return typeFactory.createJavaType(BigInteger.class);
case DECIMAL:
return typeFactory.createJavaType(BigDecimal.class);
case ENUM:
return typeFactory.createJavaType(Enum.class);
case CHOICE:
final ChoiceDataType choiceDataType = (ChoiceDataType) fieldType;
DataType widestDataType = choiceDataType.getPossibleSubTypes().get(0);

View File

@ -251,7 +251,7 @@ public class TestQueryRecord {
runner.setProperty(QueryRecord.RECORD_READER_FACTORY, "reader");
runner.setProperty(QueryRecord.RECORD_WRITER_FACTORY, "writer");
runner.setProperty(REL_NAME,
"SELECT title, name" +
"SELECT title, name, jobLevel" +
" FROM FLOWFILE" +
" WHERE CARDINALITY(addresses) > 1");
@ -270,6 +270,7 @@ public class TestQueryRecord {
final Record output = written.get(0);
assertEquals("John Doe", output.getValue("name"));
assertEquals("Software Engineer", output.getValue("title"));
assertEquals(JobLevel.IC2, output.getValue("jobLevel"));
}
@Test
@ -777,6 +778,7 @@ public class TestQueryRecord {
* {
* "name": "John Doe",
* "title": "Software Engineer",
* "jobLevel": "IC2",
* "age": 40,
* "addresses": [{
* "streetNumber": 4820,
@ -815,6 +817,7 @@ public class TestQueryRecord {
personFields.add(new RecordField("name", RecordFieldType.STRING.getDataType()));
personFields.add(new RecordField("age", RecordFieldType.INT.getDataType()));
personFields.add(new RecordField("title", RecordFieldType.STRING.getDataType()));
personFields.add(new RecordField("jobLevel", RecordFieldType.ENUM.getDataType()));
personFields.add(new RecordField("height", RecordFieldType.CHOICE.getChoiceDataType(RecordFieldType.DOUBLE.getDataType(), RecordFieldType.INT.getDataType())));
personFields.add(new RecordField("addresses", RecordFieldType.ARRAY.getArrayDataType( RecordFieldType.RECORD.getRecordDataType(addressSchema)) ));
final RecordSchema personSchema = new SimpleRecordSchema(personFields);
@ -844,6 +847,7 @@ public class TestQueryRecord {
map.put("age", 30);
map.put("height", 60.5);
map.put("title", "Software Engineer");
map.put("jobLevel", JobLevel.IC2);
map.put("addresses", new Record[] {homeAddress, workAddress});
return new MapRecord(personSchema, map);
}
@ -1281,4 +1285,10 @@ public class TestQueryRecord {
}
public enum JobLevel {
IC1,
IC2,
IC3
}
}