<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: NIfi ConvertJsonToSQL fails when Json has a array value and the column that needs to be mapped is varchar in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/NIfi-ConvertJsonToSQL-fails-when-Json-has-a-array-value-and/m-p/374859#M242167</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/106217"&gt;@Anderosn&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;The &lt;SPAN class="lia-message-read"&gt;ConvertJsonToSQL&lt;/SPAN&gt; according to the documentation will map fields only with simple type:&lt;/P&gt;&lt;P&gt;&lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.6.0/org.apache.nifi.processors.standard.ConvertJSONToSQL/index.html" target="_blank"&gt;https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.6.0/org.apache.nifi.processors.standard.ConvertJSONToSQL/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;EM&gt;...The incoming FlowFile is expected to be "flat" JSON message, meaning that it consists of a single JSON element and each field maps to a simple type...&lt;/EM&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you dont care about storing array fields as is, then you can use JoltTransformJson to convert array fields to concatenated string. The jolt spec to do this can be as the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "CARDNUMBER": "=join(',',@(1,CARDNUMBER))",
      "EXPIRYDATE": "=join(',',@(1,EXPIRYDATE))",
      "EMAIL": "=join(',',@(1,EMAIL))"
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;This will produce the following output:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "REQUESTID" : "379",
  "REQUESTTYPE" : "V",
  "REQUESTCONTEXT" : "B2B",
  "CARDNUMBER" : "5537290000000511,5537290000000522",
  "EXPIRYDATE" : "08/20,09/21",
  "EMAIL" : "John.Jones123@abcmail.com,Jason.456@gmail.com",
  "PHONENUMBER" : "11234565555"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which can be converted to SQL using the &lt;SPAN class="lia-message-read"&gt;ConvertJsonToSQL&lt;/SPAN&gt;&amp;nbsp; and all fields will be populated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that works.&lt;/P&gt;&lt;P&gt;If that helps please &lt;STRONG&gt;accept&lt;/STRONG&gt; solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Aug 2023 16:35:28 GMT</pubDate>
    <dc:creator>SAMSAL</dc:creator>
    <dc:date>2023-08-02T16:35:28Z</dc:date>
    <item>
      <title>NIfi ConvertJsonToSQL fails when Json has a array value and the column that needs to be mapped is varchar</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NIfi-ConvertJsonToSQL-fails-when-Json-has-a-array-value-and/m-p/374812#M242152</link>
      <description>&lt;P&gt;I have a json&lt;BR /&gt;&amp;nbsp;&lt;SPAN&gt;&lt;SPAN class="ui-provider cjn cjo c d e f g h i j k l m n o p q r s t cjp cjq w x y z ab ac ae af ag ah ai aj ak"&gt;{&lt;BR /&gt;&amp;nbsp; "REQUESTID" : "379",&lt;BR /&gt;&amp;nbsp; "REQUESTTYPE" : "V",&lt;BR /&gt;&amp;nbsp; "REQUESTCONTEXT" : "B2B",&lt;BR /&gt;&amp;nbsp; "CARDNUMBER" : [ "5537290000000511", "5537290000000522" ],&lt;BR /&gt;&amp;nbsp; "EXPIRYDATE" : [ "08/20", "09/21" ],&lt;BR /&gt;&amp;nbsp; "EMAIL" : [ "John.Jones123@abcmail.com", "Jason.456@gmail.com" ],&lt;BR /&gt;&amp;nbsp; "PHONENUMBER" : "11234565555"&lt;BR /&gt;}&lt;BR /&gt;CARDNUMBER, EXPIRYDATE and EMAIL are varchar in sql table&amp;nbsp;&lt;BR /&gt;when Json is passed to covertToSQL processor, I am seeing empty string in the attribute for these columns in prepared statement (Insert)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 19:38:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NIfi-ConvertJsonToSQL-fails-when-Json-has-a-array-value-and/m-p/374812#M242152</guid>
      <dc:creator>Anderosn</dc:creator>
      <dc:date>2023-08-01T19:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: NIfi ConvertJsonToSQL fails when Json has a array value and the column that needs to be mapped is varchar</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NIfi-ConvertJsonToSQL-fails-when-Json-has-a-array-value-and/m-p/374859#M242167</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/106217"&gt;@Anderosn&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;The &lt;SPAN class="lia-message-read"&gt;ConvertJsonToSQL&lt;/SPAN&gt; according to the documentation will map fields only with simple type:&lt;/P&gt;&lt;P&gt;&lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.6.0/org.apache.nifi.processors.standard.ConvertJSONToSQL/index.html" target="_blank"&gt;https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.6.0/org.apache.nifi.processors.standard.ConvertJSONToSQL/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;EM&gt;...The incoming FlowFile is expected to be "flat" JSON message, meaning that it consists of a single JSON element and each field maps to a simple type...&lt;/EM&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you dont care about storing array fields as is, then you can use JoltTransformJson to convert array fields to concatenated string. The jolt spec to do this can be as the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "CARDNUMBER": "=join(',',@(1,CARDNUMBER))",
      "EXPIRYDATE": "=join(',',@(1,EXPIRYDATE))",
      "EMAIL": "=join(',',@(1,EMAIL))"
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;This will produce the following output:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "REQUESTID" : "379",
  "REQUESTTYPE" : "V",
  "REQUESTCONTEXT" : "B2B",
  "CARDNUMBER" : "5537290000000511,5537290000000522",
  "EXPIRYDATE" : "08/20,09/21",
  "EMAIL" : "John.Jones123@abcmail.com,Jason.456@gmail.com",
  "PHONENUMBER" : "11234565555"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which can be converted to SQL using the &lt;SPAN class="lia-message-read"&gt;ConvertJsonToSQL&lt;/SPAN&gt;&amp;nbsp; and all fields will be populated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that works.&lt;/P&gt;&lt;P&gt;If that helps please &lt;STRONG&gt;accept&lt;/STRONG&gt; solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 16:35:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NIfi-ConvertJsonToSQL-fails-when-Json-has-a-array-value-and/m-p/374859#M242167</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-08-02T16:35:28Z</dc:date>
    </item>
  </channel>
</rss>

