diff --git a/nifi-standardize-date-nar/pom.xml b/nifi-standardize-date-nar/pom.xml
index ec759be..27ae4f5 100644
--- a/nifi-standardize-date-nar/pom.xml
+++ b/nifi-standardize-date-nar/pom.xml
@@ -19,11 +19,11 @@
com.nineteen04labs
nifi-standardize-date-bundle
- 18.07.2
+ 18.07.3
nifi-standardize-date-nar
- 18.07.2
+ 18.07.3
nar
true
@@ -34,7 +34,7 @@
com.nineteen04labs
nifi-standardize-date-processors
- 18.07.2
+ 18.07.3
diff --git a/nifi-standardize-date-processors/pom.xml b/nifi-standardize-date-processors/pom.xml
index 6d15642..1a402ec 100644
--- a/nifi-standardize-date-processors/pom.xml
+++ b/nifi-standardize-date-processors/pom.xml
@@ -20,7 +20,7 @@
com.nineteen04labs
nifi-standardize-date-bundle
- 18.07.2
+ 18.07.3
nifi-standardize-date-processors
@@ -40,16 +40,36 @@
commons-io
2.6
+
org.apache.avro
avro
- 1.8.2
+ 1.8.0
+ system
+ ${project.basedir}/src/main/resources/avro-1.8.0-zolyfarkas.jar
- org.apache.avro
- avro-tools
- 1.8.2
+ org.codehaus.jackson
+ jackson-core-asl
+ 1.9.13
+
+
+ org.codehaus.jackson
+ jackson-mapper-asl
+ 1.9.13
+
+
+ com.google.guava
+ guava
+ 19.0
+
+
+ org.xerial.snappy
+ snappy-java
+ 1.1.7.2
+
+
com.fasterxml.jackson.core
jackson-databind
diff --git a/nifi-standardize-date-processors/src/main/java/com/nineteen04labs/processors/standardizedate/StandardizeDate.java b/nifi-standardize-date-processors/src/main/java/com/nineteen04labs/processors/standardizedate/StandardizeDate.java
index 4f908a8..685427e 100644
--- a/nifi-standardize-date-processors/src/main/java/com/nineteen04labs/processors/standardizedate/StandardizeDate.java
+++ b/nifi-standardize-date-processors/src/main/java/com/nineteen04labs/processors/standardizedate/StandardizeDate.java
@@ -52,6 +52,7 @@
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.processor.io.StreamCallback;
+import org.codehaus.jackson.node.NullNode;
@Tags({"date", "time", "datetime", "standardize", "standardization"})
@CapabilityDescription("NiFi processor to standardize date fields in a FlowFile.")
@@ -123,7 +124,7 @@ public void process(InputStream in, OutputStream out) throws IOException {
for(Schema.Field f : schemaFields) {
Schema.Field oldField = new Schema.Field(f.name(), f.schema(), f.doc(), f.defaultVal());
newSchemaFields.add(oldField);
- }
+ }
in = FormatStream.avroToJson(in, schema);
}
@@ -146,15 +147,27 @@ public void process(InputStream in, OutputStream out) throws IOException {
String invalidDate = jsonParser.getText();
String invalidDateFormat = invalidDates.get(tokenString);
String standardizedDate;
+
try {
- standardizedDate = ManipulateDate.standardize(invalidDate, invalidDateFormat, timezone);
+ if (invalidDate != "null") {
+ standardizedDate = ManipulateDate.standardize(invalidDate, invalidDateFormat, timezone);
+ jsonGen.writeString(standardizedDate);
+ }
+ else
+ jsonGen.writeNull();
} catch (Exception e) {
throw new ProcessException("Couldn't convert '" + invalidDate + "' with format '" + invalidDateFormat + "' with timezone '" + timezone + "'");
}
- jsonGen.writeString(standardizedDate);
- if (flowFormat == "AVRO")
- newSchemaFields.add(new Schema.Field(newFieldName, Schema.create(Type.STRING), null, "null"));
+ if (flowFormat == "AVRO") {
+ if (schema.getField(tokenString).schema().getType() == Schema.Type.UNION) {
+ ArrayList unionSchema = new ArrayList<>();
+ unionSchema.add(Schema.create(Schema.Type.NULL));
+ unionSchema.add(Schema.create(Schema.Type.STRING));
+ newSchemaFields.add(new Schema.Field(newFieldName, Schema.createUnion(unionSchema), null, NullNode.getInstance()));
+ } else
+ newSchemaFields.add(new Schema.Field(newFieldName, Schema.create(Type.STRING), null, "null"));
+ }
}
}
jsonGen.writeRaw("\n");
diff --git a/nifi-standardize-date-processors/src/main/java/com/nineteen04labs/processors/util/FormatStream.java b/nifi-standardize-date-processors/src/main/java/com/nineteen04labs/processors/util/FormatStream.java
index 1f1451a..de424ac 100644
--- a/nifi-standardize-date-processors/src/main/java/com/nineteen04labs/processors/util/FormatStream.java
+++ b/nifi-standardize-date-processors/src/main/java/com/nineteen04labs/processors/util/FormatStream.java
@@ -27,14 +27,14 @@
import org.apache.avro.file.CodecFactory;
import org.apache.avro.file.DataFileStream;
import org.apache.avro.file.DataFileWriter;
+import org.apache.avro.generic.ExtendedGenericDatumWriter;
import org.apache.avro.generic.GenericDatumReader;
import org.apache.avro.generic.GenericDatumWriter;
import org.apache.avro.io.DatumReader;
import org.apache.avro.io.DatumWriter;
import org.apache.avro.io.Decoder;
-import org.apache.avro.io.DecoderFactory;
-import org.apache.avro.io.EncoderFactory;
-import org.apache.avro.io.JsonEncoder;
+import org.apache.avro.io.ExtendedJsonDecoder;
+import org.apache.avro.io.ExtendedJsonEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,10 +45,10 @@ public class FormatStream {
public static InputStream avroToJson(InputStream in, Schema schema) throws IOException {
GenericDatumReader