<?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 Concatenate two JSON values in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Concatenate-two-JSON-values/m-p/362564#M238801</link>
    <description>&lt;P&gt;I have a JSON dataset and need to create a unique key from it. No single field is unique, but the first two, together, are. What I want to convert from:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[{"airport":"KDEN", "runway":"16R", "length":16000}, ...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I want to concatenate the "airport" and "runway" values to create this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[{"key":"KDEN/16R", "airport":"KDEN", "runway":"16R", "length":16000}, ...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got it working with an ugly anti-pattern of SplitRecord,&amp;nbsp;EvaluateJSONPath, UpdateAttribute, and AttributesToJSON&amp;nbsp; which changes each flow file to several thousand, but am looking for a better way to do this.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jan 2023 19:28:44 GMT</pubDate>
    <dc:creator>bbbbbb</dc:creator>
    <dc:date>2023-01-30T19:28:44Z</dc:date>
    <item>
      <title>Concatenate two JSON values</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Concatenate-two-JSON-values/m-p/362564#M238801</link>
      <description>&lt;P&gt;I have a JSON dataset and need to create a unique key from it. No single field is unique, but the first two, together, are. What I want to convert from:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[{"airport":"KDEN", "runway":"16R", "length":16000}, ...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I want to concatenate the "airport" and "runway" values to create this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[{"key":"KDEN/16R", "airport":"KDEN", "runway":"16R", "length":16000}, ...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got it working with an ugly anti-pattern of SplitRecord,&amp;nbsp;EvaluateJSONPath, UpdateAttribute, and AttributesToJSON&amp;nbsp; which changes each flow file to several thousand, but am looking for a better way to do this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 19:28:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Concatenate-two-JSON-values/m-p/362564#M238801</guid>
      <dc:creator>bbbbbb</dc:creator>
      <dc:date>2023-01-30T19:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate two JSON values</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Concatenate-two-JSON-values/m-p/362587#M238803</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are multiple ways you can resolve this issue without having to do all processors you mentioned above. Some options:&lt;/P&gt;&lt;P&gt;1- QueryRecord&lt;/P&gt;&lt;P&gt;2- UpdateRecord&lt;/P&gt;&lt;P&gt;3- JsonJoltTransformation.&lt;/P&gt;&lt;P&gt;If you elect to use QueryRecord which is what is been suggested for such anti-pattern , then you can create new dynamic property on the QueryRecord to represent the new relationship which will have the result of the select statement with new Key field as follows :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAMSAL_0-1675117781675.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/36686i46F41247F22CAE39/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAMSAL_0-1675117781675.png" alt="SAMSAL_0-1675117781675.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The select query syntax for the "AddKeyRel":&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;select *,airport||'/'||runway as key from FlowFile&lt;/LI-CODE&gt;&lt;P&gt;The || symbol is used for concatenation in such query and processor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The JsonTreeReader and the JsonRecordSetWriter are configured as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAMSAL_1-1675117960341.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/36687iE093EC4117CA5019/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAMSAL_1-1675117960341.png" alt="SAMSAL_1-1675117960341.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAMSAL_2-1675117983804.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/36688i8165F341FE99D47D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAMSAL_2-1675117983804.png" alt="SAMSAL_2-1675117983804.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the 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>Mon, 30 Jan 2023 22:34:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Concatenate-two-JSON-values/m-p/362587#M238803</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-01-30T22:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate two JSON values</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Concatenate-two-JSON-values/m-p/362869#M238854</link>
      <description>&lt;P&gt;That worked perfectly. Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 22:27:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Concatenate-two-JSON-values/m-p/362869#M238854</guid>
      <dc:creator>bbbbbb</dc:creator>
      <dc:date>2023-02-01T22:27:26Z</dc:date>
    </item>
  </channel>
</rss>

