I’ve been trying to get data to partition into multiple files using a JSONWriter and though I thought I had it distilled into a simple case, but it is not working properly in two ways.
- I have flattened my data into a single input port that has a field called “catalog_id” that is the partition key. For my testing there are 3 data records coming in holding product data, each one has a different catalog_id. Ergo, I would expect to get 3 files where each file has a single product element only inside the catalog element.
What is happening is I am getting 3 files named properly, but each file has ALL products in it regardless of what catalog_id they belonged to. (See attached xml files)
I’ve attached a screenshot of the input data and my jsonwriter setup and the following is my Mapping:
Screen Shot 2017-04-12 at 12.08.29 PM.png
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:clover="http://www.cloveretl.com/ns/xmlmapping" xmlns="http://www.demandware.com/xml/impex/catalog/2006-10-31" catalog-id="$0.catalog_id" clover:inPort="0">
<category category-id="$0.record_id" clover:inPort="0" clover:writeNullElement="false">
<custom-attributes clover:writeNullElement="false">
<custom-attribute attribute-id="sdx_noindex" clover:writeNullElement="false">$0.noindex</custom-attribute>
<custom-attribute attribute-id="sdx_metatitle_auto" clover:writeNullElement="false">$0.metatitle_auto</custom-attribute>
<custom-attribute attribute-id="sdx_metatitle_override" clover:writeNullElement="false">$0.metatitle_override</custom-attribute>
<custom-attribute attribute-id="sdx_metadescription_auto" clover:writeNullElement="false">$0.metadescription_auto</custom-attribute>
<custom-attribute attribute-id="sdx_metadescription_override" clover:writeNullElement="false">$0.metadescription_override</custom-attribute>
<custom-attribute attribute-id="sdx_h1_auto" clover:writeNullElement="false">$0.h1_auto</custom-attribute>
<custom-attribute attribute-id="sdx_h1_override" clover:writeNullElement="false">$0.h1_override</custom-attribute>
<custom-attribute attribute-id="sdx_canonical_auto" clover:writeNullElement="false">$0.canonical_auto</custom-attribute>
<custom-attribute attribute-id="sdx_canonical_override" clover:writeNullElement="false">$0.canonical_override</custom-attribute>
<custom-attribute attribute-id="sdx_schema_org_auto" clover:writeNullElement="false">$0.schemaorg_auto</custom-attribute>
<custom-attribute attribute-id="sdx_schema_org_override" clover:writeNullElement="false">$0.schemaorg_override</custom-attribute>
<custom-attribute attribute-id="sdx_opengraph_auto" clover:writeNullElement="false">$0.opengraph_auto</custom-attribute>
<custom-attribute attribute-id="sdx_opengraph_override" clover:writeNullElement="false">$0.opengraph_override</custom-attribute>
</custom-attributes>
</category>
<product product-id="$0.p_record_id" clover:inPort="0" clover:writeNullElement="false">
<custom-attributes clover:writeNullElement="false">
<custom-attribute attribute-id="sdx_noindex" clover:writeNullElement="false">$0.p_noindex</custom-attribute>
<custom-attribute attribute-id="sdx_metatitle_auto" clover:writeNullElement="false">$0.p_metatitle_auto</custom-attribute>
<custom-attribute attribute-id="sdx_metatitle_override" clover:writeNullElement="false">$0.p_metatitle_override</custom-attribute>
<custom-attribute attribute-id="sdx_metadescription_auto" clover:writeNullElement="false">$0.p_metadescription_auto</custom-attribute>
<custom-attribute attribute-id="sdx_metadescription_override" clover:writeNullElement="false">$0.p_metadescription_override</custom-attribute>
<custom-attribute attribute-id="sdx_h1_auto" clover:writeNullElement="false">$0.p_h1_auto</custom-attribute>
<custom-attribute attribute-id="sdx_h1_override" clover:writeNullElement="false">$0.p_h1_override</custom-attribute>
<custom-attribute attribute-id="sdx_canonical_auto" clover:writeNullElement="false">$0.p_canonical_auto</custom-attribute>
<custom-attribute attribute-id="sdx_canonical_override" clover:writeNullElement="false">$0.p_canonical_override</custom-attribute>
<custom-attribute attribute-id="sdx_schema_org_auto" clover:writeNullElement="false">$0.p_schemaorg_auto
</custom-attribute>
<custom-attribute attribute-id="sdx_schema_org_override" clover:writeNullElement="false">$0.p_schemaorg_override
</custom-attribute>
<custom-attribute attribute-id="sdx_opengraph_auto" clover:writeNullElement="false">$0.p_opengraph_auto
</custom-attribute>
<custom-attribute attribute-id="sdx_opengraph_override" clover:writeNullElement="false">
$0.p_opengraph_override
</custom-attribute>
</custom-attributes>
</product>
</catalog>
The logs show no useful info as no error is being thrown.
- Additionally, since I have flattened my category & product data into single records (as I only had the option of using a partition key on the last port added to the JSONWriter and I couldn’t see a way to populate the catalog-id attribute in the root element from the partition key anyway) I need to hide the element completely for products (ie. which have only the p_ and catalog_id fields populated) and the element completely for categories (i.e rows that do not have any of the p_ fields populated).
The customers data realistically may have products and categories in different catalogs, and when I had the product data coming in on one port and the category data on another, if there were no categories (the 0 port) then the file was always empty.
In this particular test data, I have only products and no categories so the values of all category mapped fields are null, l but I am still getting the skeleton of the category in the file despite having “writeNullElement=false” on every element. (see xml files and mapping above).
Any assistance you can give with these issues is greatly appreciated!