You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Mark Woodcock <wo...@usna.edu.INVALID> on 2023/10/06 22:03:48 UTC
JOLTTransformRecord problem
Howdy,
Given the jolt spec which I arrived at with the help I received in the
previous issue (flattening record schemas):
[
{
"operation": "shift",
"spec": { "*": "record.&" }
},
{
"operation": "shift",
"spec": {
"record": {
"*": {
"$": "TValue[#2].name",
"@": "TValue[#2].value"
}
}
}
},
{
"operation": "default",
"spec": { "TValue[]": { "*": { "class": "unclass" } } }
}
]
and some input json that looks like this:
{
"datetime": "2023-08-24 17:07:03.334170+00:00",
"ShipId": 367375970,
"Latitude": 44.09750833333333,
"Longitude": -68.98625999999999,
"Course": 275.1,
"Speed": 11,
"name": "",
"draft": "",
"dimensions": {
"A": 192,
"B": 32,
"C": 13,
"D": 19
},
"destination": "",
"StatID": "",
"Eta": {
"Day": 15,
"Hour": 6,
"Minute": 0,
"Month": 8
}
}
I note that while the JOLT Demo page (
https://jolt-demo.appspot.com/#hashDefault) happily completes the
transform, JOLTTransformRecord process is not so happy, and gives errors
for either of the fields that have "records" as the value:
Cannot convert value [MapRecord[{A: 192,B: 32,C: 13,D: 19}]] of
CHOICE[STRING,RECORD] to Map for field dimensions because type is not
supported.
(n.b. if I blank out the value of the dimensions value [make it a null
string], I get a similar error message for the Eta field.)
Is the JOLT processor deliberately not handling something?
Is the JOLT demo absurdly generous about something?
Is there a way 'round?
thx,
mew
Re: JOLTTransformRecord problem
Posted by Matt Burgess <ma...@apache.org>.
mew,
What version of NiFi are you using? We may have fixed the bug in newer
versions but if you are using the latest, this is bug. We shouldn't
infer CHOICE[STRING,RECORD] when the only entry is a RECORD.
Since you only have one top-level record in your FlowFile you can use
JoltTransformJSON instead as a workaround. If you want JSON output
then it's a solution and not a workaround :) The error here isn't
about JOLT but about JoltTransformRecord using NiFi Records to apply
the transformation to rather than the raw JSON (the latter is what
JoltTransformJSON does).
Regards,
Matt