You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by tu...@apache.org on 2023/05/26 09:10:16 UTC
[nifi] 02/02: NIFI-11590: Missing Enum data type handling in FlowFileTable
This is an automated email from the ASF dual-hosted git repository.
turcsanyi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
commit cfd62c9511e43d5010fbfbb12b98b40bdfdb3fc2
Author: Mark Bathori <ba...@gmail.com>
AuthorDate: Thu May 25 14:41:42 2023 +0200
NIFI-11590: Missing Enum data type handling in FlowFileTable
This closes #7294.
Signed-off-by: Peter Turcsanyi <tu...@apache.org>
---
.../main/java/org/apache/nifi/queryrecord/FlowFileTable.java | 2 ++
.../org/apache/nifi/processors/standard/TestQueryRecord.java | 12 +++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/queryrecord/FlowFileTable.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/queryrecord/FlowFileTable.java
index a2debbdce5..e462972387 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/queryrecord/FlowFileTable.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/queryrecord/FlowFileTable.java
@@ -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);
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestQueryRecord.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestQueryRecord.java
index 20f6dca199..d8a9a1f069 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestQueryRecord.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestQueryRecord.java
@@ -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
+ }
+
}