<?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: How to Transform an Avro to a Super-Schema Avro? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Transform-an-Avro-to-a-Super-Schema-Avro/m-p/200050#M62460</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jun 2017 03:48:41 GMT</pubDate>
    <dc:creator>cstanca</dc:creator>
    <dc:date>2017-06-08T03:48:41Z</dc:date>
    <item>
      <title>How to Transform an Avro to a Super-Schema Avro?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Transform-an-Avro-to-a-Super-Schema-Avro/m-p/200047#M62457</link>
      <description>&lt;P&gt;Assume a data file in avro schema "avro schema short".&lt;/P&gt;&lt;P&gt;Assume "avro schema full" that is inclusive of the "avro schema short" and has some additional fields, set for default values. &lt;/P&gt;&lt;P&gt;The short schema Avro can have fields in any order and field-wise is a sub-set of the super-schema with fields not necessarily in the same order.&lt;/P&gt;&lt;P&gt;How would one use NiFi out-of-box processors to transform the first data file into "avro schema full" setting the values for the additional fields to the default values as specified in the "avro schema full"? It could be a creative solution involving one of those Execute ... or Scripted ... processors.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 08:52:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Transform-an-Avro-to-a-Super-Schema-Avro/m-p/200047#M62457</guid>
      <dc:creator>cstanca</dc:creator>
      <dc:date>2017-06-07T08:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Transform an Avro to a Super-Schema Avro?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Transform-an-Avro-to-a-Super-Schema-Avro/m-p/200048#M62458</link>
      <description>&lt;P&gt;As of NiFi 1.2.0, you can use &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.2.0/org.apache.nifi.processors.standard.ConvertRecord/index.html"&gt;ConvertRecord&lt;/A&gt;, after configuring an &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services-nar/1.2.0/org.apache.nifi.avro.AvroReader/index.html"&gt;AvroReader&lt;/A&gt; with the short schema and an &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services-nar/1.2.0/org.apache.nifi.avro.AvroRecordSetWriter/index.html"&gt;AvroRecordSetWriter&lt;/A&gt; with the super schema.&lt;/P&gt;&lt;P&gt;Prior to NiFi 1.2.0, you may be able to use &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-kite-nar/1.2.0/org.apache.nifi.processors.kite.ConvertAvroSchema/index.html"&gt;ConvertAvroSchema&lt;/A&gt;, using the super-schema as both Input and Output Schema property values (if you use the short schema as Input, the processor complains about the unmapped fields in the super schema). I tried this by adding a single field to my "short schema" to make the "super schema":&lt;/P&gt;&lt;PRE&gt;{"name": "extra_field", "type": "string", "default": "Hello"}&lt;/PRE&gt;&lt;P&gt;I'm not sure if this will work with arbitrary super-sets, but it is worth a try &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 20:33:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Transform-an-Avro-to-a-Super-Schema-Avro/m-p/200048#M62458</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2017-06-07T20:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to Transform an Avro to a Super-Schema Avro?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Transform-an-Avro-to-a-Super-Schema-Avro/m-p/200049#M62459</link>
      <description>&lt;P&gt;I agree with what Matt said above and I had been working on a template to achieve this before I saw his answer so figured I would post it anyway...&lt;/P&gt;&lt;P&gt;I made up the following two schemas:&lt;/P&gt;&lt;PRE&gt;{"name": "shortSchema",  
"namespace": "nifi",  
"type": "record",  
"fields": [  
 { "name": "a", "type": "string" },  
 { "name": "b", "type": "string" }  
]}&lt;/PRE&gt;&lt;PRE&gt;{"name": "fullSchema",  
"namespace": "nifi",  
"type": "record",  
"fields": [  
 { "name": "c", "type": ["null", "string"], "default" : "default value for field c" },  
 { "name": "d", "type": ["null", "string"], "default" : "default value for field d" },  
 { "name": "a", "type": "string" },  
 { "name": "b", "type": "string" }  
]}&lt;/PRE&gt;&lt;P&gt;Then made the following flow:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="16116-convertrecordprocessors.png" style="width: 385px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17585i77EC8F1E725EAAA6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="16116-convertrecordprocessors.png" alt="16116-convertrecordprocessors.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="16115-convertrecordservices.png" style="width: 1527px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17586iC94D6971C8F5B052/image-size/medium?v=v2&amp;amp;px=400" role="button" title="16115-convertrecordservices.png" alt="16115-convertrecordservices.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What this flow does it the following:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Generate a CSV with two rows and the columns a,b,c&lt;/LI&gt;&lt;LI&gt;Reads the CSV using the shortSchema and writes as Avro with the shortSchema&lt;/LI&gt;&lt;LI&gt;Updates the schema.name attribute to fullSchema&lt;/LI&gt;&lt;LI&gt;Reads the Avro using the embedded schema (shortSchema) and writes it using the schema from schema.name (fullSchema)&lt;/LI&gt;&lt;LI&gt;Reads the Avro using the embedded schema (fullSchema) and writes it back to CSV&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;At the end the CSV that is printed now has the new fields with default values filled in.&lt;/P&gt;&lt;P&gt;The CSV part is just for being able to easily see what is going on and is obviously not required if you already have Avro data.&lt;/P&gt;&lt;P&gt;Here is a template of the flow:  &lt;A href="https://community.cloudera.com/legacyfs/online/attachments/16117-convert-avro-short-to-full.xml" target="_blank"&gt;convert-avro-short-to-full.xml&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 05:48:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Transform-an-Avro-to-a-Super-Schema-Avro/m-p/200049#M62459</guid>
      <dc:creator>bbende</dc:creator>
      <dc:date>2019-08-18T05:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to Transform an Avro to a Super-Schema Avro?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Transform-an-Avro-to-a-Super-Schema-Avro/m-p/200050#M62460</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 03:48:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-Transform-an-Avro-to-a-Super-Schema-Avro/m-p/200050#M62460</guid>
      <dc:creator>cstanca</dc:creator>
      <dc:date>2017-06-08T03:48:41Z</dc:date>
    </item>
  </channel>
</rss>

