This is an automated email from the ASF dual-hosted git repository.
mattyb149 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/master by this push:
new b6ef7e1 NIFI-7462: This adds a way to convert or cast a choice object
into a valid type for use with calcite query functions
b6ef7e1 is described below
commit b6ef7e13bf076fb88fd94ce49d2a217db3f19aaa
Author: pcgrenier
AuthorDate: Fri May 15 20:03:01 2020 -0400
NIFI-7462: This adds a way to convert or cast a choice object into a valid
type for use with calcite query functions
NIFI-7462: Update to allow FlowFile Table's schema to be more intelligent
when using CHOICE types
NIFI-7462: Fixed checkstyle violation, removed documentation around the
CAST functions that were no longer needed
Signed-off-by: Matthew Burgess
This closes #4282
---
.../nifi/processors/standard/QueryRecord.java | 26 ++---
.../org/apache/nifi/queryrecord/FlowFileTable.java | 58 +
.../nifi/processors/standard/TestQueryRecord.java | 129 +
3 files changed, 199 insertions(+), 14 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/QueryRecord.java
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/QueryRecord.java
index 82aea6f..a620a60 100644
---
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/QueryRecord.java
+++
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/QueryRecord.java
@@ -784,12 +784,6 @@ public class QueryRecord extends AbstractProcessor {
}
}
-public static class RecordRecordPath extends RecordPathFunction {
-public Record eval(Object record, String recordPath) {
-return eval(record, recordPath, Record.class::cast);
-}
-}
-
public static class RecordPathFunction {
private static final RecordField ROOT_RECORD_FIELD = new
RecordField("root",
RecordFieldType.MAP.getMapDataType(RecordFieldType.STRING.getDataType()));
@@ -803,14 +797,18 @@ public class QueryRecord extends AbstractProcessor {
return null;
}
-if (record instanceof Record) {
-return eval((Record) record, recordPath, transform);
-} else if (record instanceof Record[]) {
-return eval((Record[]) record, recordPath, transform);
-} else if (record instanceof Iterable) {
-return eval((Iterable) record, recordPath, transform);
-} else if (record instanceof Map) {
-return eval((Map) record, recordPath, transform);
+try {
+if (record instanceof Record) {
+return eval((Record) record, recordPath, transform);
+} else if (record instanceof Record[]) {
+return eval((Record[]) record, recordPath, transform);
+} else if (record instanceof Iterable) {
+return eval((Iterable) record, recordPath,
transform);
+} else if (record instanceof Map) {
+return eval((Map) record, recordPath, transform);
+}
+} catch (IllegalArgumentException e) {
+throw new RuntimeException("Cannot evaluate RecordPath " +
recordPath + " against " + record, e);
}
throw new RuntimeException("Cannot evaluate RecordPath " +
recordPath + " against given argument because the argument is of type " +
record.getClass() + " instead of Record");
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 3030008..18cbc63 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
@@ -43,6 +43,7 @@ import org.apache.nifi.serialization.record.Record;
import org.apache.nifi.serialization.record.RecordField;
import org.apache.nifi.serialization.record.RecordSchema;
import org.apache.nifi.serialization.record.type.ArrayDataType;
+import org.apache.nifi.serialization.record.type.ChoiceDataType;
import java.lang.reflect.Type;
import java.math.BigInteger;
@@ -223,12 +224,69 @@ public class FlowFileTable extends AbstractTable
implements QueryableTable, Tran
case BIGINT:
return typeFactory.createJavaType(BigInteger.class);