[
https://issues.apache.org/jira/browse/NIFI-14162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17947937#comment-17947937
]
Daniel Stieglitz edited comment on NIFI-14162 at 4/28/25 8:33 PM:
------------------------------------------------------------------
[~exceptionfactory] I just tried with schema
{code:java}
{
"type":"record",
"name":"nifiRecord",
"namespace":"org.apache.nifi",
"fields":[{"name":"firstName","type":["string","null"]},{"name":"lastName","type":["string","null"]}]
}{code}
and query
{code:java}
select lastName, firstName from FLOWFILE
{code}
with incoming data as
{code:java}
[{
"firstName" : "Joe",
"lastName" : "Smith"
},
{
"firstName" : "Bob",
"lastName" : "Jones"
}]{code}
and the query result was
{code:java}
[ {
"lastName" : "Joe",
"firstName" : "Smith"
}, {
"lastName" : "Bob",
"firstName" : "Jones"
} ]{code}
was (Author: JIRAUSER294662):
[~exceptionfactory] I just tried with schema
{code:java}
{
"type":"record",
"name":"nifiRecord",
"namespace":"org.apache.nifi",
"fields":[{"name":"firstName","type":["string","null"]},{"name":"lastName","type":["string","null"]}]
}{code}
and query
{code:java}
select lastName, firstName from FLOWFILE
{code}
with incoming data as
{code:java}
[{
"firstName" : "Joe",
"lastName" : "Smith"
},
{
"firstName" : "Bob",
"lastName" : "Jones"
}]{code}
and the result was
{code:java}
[ {
"lastName" : "Joe",
"firstName" : "Smith"
}, {
"lastName" : "Bob",
"firstName" : "Jones"
} ]{code}
> QueryRecord not following column order
> --------------------------------------
>
> Key: NIFI-14162
> URL: https://issues.apache.org/jira/browse/NIFI-14162
> Project: Apache NiFi
> Issue Type: Bug
> Affects Versions: 2.0.0
> Reporter: alexduta
> Assignee: Daniel Stieglitz
> Priority: Minor
>
> It seems that, in Nifi, in the QueryRecord processor, if you define some
> columns you select from flowfile, it is following the order, but is taking
> the values in their order from the original flowfile.
> As an example:
> Original Json flowfile:
> {code:java}
> // [{
> "ArticleCode" : "12345",
> "ProductCode" : "10101",
> "ArticleName" : "Credit Card",
> "ProductName" : "Porduct Credit",
> "Country" : "RO"
> }] {code}
>
>
> Query:
>
> {code:java}
> // select ArticleCode,ArticleName,ProductCode,ProductName,Country from
> FLOWFILE
> {code}
>
>
> Returning file:
>
> {code:java}
> // [{
> "ArticleCode" : "12345",
> "ArticleName" : "10101",
> "ProductCode" : "Credit Card",
> "ProductName" : "Porduct Credit",
> "Country" : "RO"
> }] {code}
>
> So, it is somehow just adding the name of the columns, but is not changing
> the values.
>
> Otherwise, if one of the records in the flowfile has the correct order in it,
> the others will follow the correct rule:
> Original file:
> {code:java}
> // [{
> "ArticleCode" : "12345",
> "ArticleName" : "Credit Card",
> "ProductCode" : "10101",
> "ProductName" : "Porduct Credit",
> "Country" : "RO"
> },
> {
> "ArticleCode" : "12346",
> "ProductCode" : "10102",
> "ArticleName" : "Business Card",
> "ProductName" : "Society Credit",
> "Country" : "RO"
> }] {code}
> or
> {code:java}
> // [
> {
> "ArticleCode" : "12345",
> "ProductCode" : "10101",
> "ArticleName" : "Credit Card",
> "ProductName" : "Porduct Credit",
> "Country" : "RO"
> },{
> "ArticleCode" : "12346",
> "ArticleName" : "Business Card",
> "ProductCode" : "10102",
> "ProductName" : "Society Credit",
> "Country" : "RO"
> }] {code}
> Returning file:
> {code:java}
> // [{
> "ArticleCode" : "12345",
> "ArticleName" : "Credit Card",
> "ProductCode" : "10101",
> "ProductName" : "Porduct Credit",
> "Country" : "RO"
> },
> {
> "ArticleCode" : "12346",
> "ArticleName" : "Business Card",
> "ProductCode" : "10102",
> "ProductName" : "Society Credit",
> "Country" : "RO"
> }] {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)