简体   繁体   中英

Apache NiFi QueryRecord SELECT Static Alias Column

I want to import a file that has the following Avro schema assigned using Apache NiFi:

{
   "type" : "record",
   "namespace" : "SomeSpaceName",
   "name" : "SampleFile",
   "fields" : [
     { "name" : "PersonName" , "type" : "string" },
     { "name" : "PersonType" , "type" : "string" }
   ]
}

When I use the QueryRecord processor I want to have a static field in the output file so I can import it into MongoDB. The query is:

SELECT LOWER(PersonName) as _id,
'Male' as gender
FROM flowfile

The problem is Calcite will not add the new static field properly. It adds the name successfully but the new gender field only contains the first letter of the word:

| _id  | gender |
|------|--------|
| Eric | M      |
| Bill | M      |
| Chad | M      |

Make sure QueryRecord processor writer avro schema have _id,gender fields included in it.

Writer Avro Schema:

{
   "type" : "record",
   "namespace" : "SomeSpaceName",
   "name" : "SampleFile",
   "fields" : [
     { "name" : "_id" , "type" : ["null","string"] },
     { "name" : "gender" , "type" : ["null","string"] }
   ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM