[ 
https://issues.apache.org/jira/browse/NIFI-14162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17974015#comment-17974015
 ] 

Daniel Stieglitz edited comment on NIFI-14162 at 6/13/25 7:37 PM:
------------------------------------------------------------------

I followed the Calcite tutorial and tried to apply the exact scenario in this 
ticket but as CSV so I could easily modify the model files they have there. I 
created a directory under calcite/example/csv/src/test/resources named products 
where I placed a CSV file named ITEMS.csv which contains the following:
{code:java}
ARTICLECODE:string,PRODUCTCODE:string,ARTICLENAME:string,PRODUCTNAME:string,COUNTRY:string
"12345","10101","Credit Card","Porduct Credit","RO"{code}
I modified the model.json, model-with-custom-table.json and smart.json 
accordingly to either look at the products directory alone and for 
model-with-custom-table.json specifying the ITEMS.csv file also.

I connected to each of these models in the shell (i.e. running ./sqlline as 
specified in the tutorial) and I was able to run a query reversing the order of 
the column names
{code:java}
select Country,ProductName,ArticleName,Productcode,ArticleCode FROM items;{code}
and I got the correct results
{code:java}
+---------+----------------+-------------+-------------+-------------+
| COUNTRY |  PRODUCTNAME   | ARTICLENAME | PRODUCTCODE | ARTICLECODE |
+---------+----------------+-------------+-------------+-------------+
| RO      | Porduct Credit | Credit Card | 10101       | 12345       |
+---------+----------------+-------------+-------------+-------------+ {code}
 


was (Author: JIRAUSER294662):
I followed the Calcite tutorial and tried to apply the exact scenario in this 
ticket but as CSV so I could easily modify the model files they have there. I 
created a directory under calcite/example/csv/src/test/resources named products 
where I placed a CSV file named ITEMS.csv which contains the following:

 
{code:java}
ARTICLECODE:string,PRODUCTCODE:string,ARTICLENAME:string,PRODUCTNAME:string,COUNTRY:string
"12345","10101","Credit Card","Porduct Credit","RO"{code}
 

I modified the model.json, model-with-custom-table.json and smart.json 
accordingly to either look at the products directory alone and for 
model-with-custom-table.json specifying the ITEMS.csv file also.

I connected to each of these models in the shell (i.e. running ./sqlline as 
specified in the tutorial) and I was able to run a query reversing the order of 
the column names

 
{code:java}
select Country,ProductName,ArticleName,Productcode,ArticleCode FROM items;{code}
and I got the correct results
{code:java}
+---------+----------------+-------------+-------------+-------------+
| COUNTRY |  PRODUCTNAME   | ARTICLENAME | PRODUCTCODE | ARTICLECODE |
+---------+----------------+-------------+-------------+-------------+
| RO      | Porduct Credit | Credit Card | 10101       | 12345       |
+---------+----------------+-------------+-------------+-------------+ {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)

Reply via email to