<?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 Nifi Lookup CSV values with SQL NULL values in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351560#M236309</link>
    <description>&lt;P&gt;Hi, I need to compare several csv columns with values from my db. To do so I use the LookupRecord with concat various csv columns and the corresponding concat of sql columns in the DatabaseRecordLookupService. This works fine as long as I do not have any NULL values in my db.&lt;/P&gt;&lt;P&gt;If there is a NULL value the Lookup Processor always routes those datasets to unmatched, as an empty string in the csv does not match the NULL values from the db.&lt;/P&gt;&lt;P&gt;What needs to be written in the corresponding csv column so that it matches the db NULL value?&lt;/P&gt;&lt;P&gt;I already tried to insert 'null', 'NULL' and 0 in the csv but it never matched the db value.&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
    <pubDate>Tue, 06 Sep 2022 09:30:59 GMT</pubDate>
    <dc:creator>code</dc:creator>
    <dc:date>2022-09-06T09:30:59Z</dc:date>
    <item>
      <title>Nifi Lookup CSV values with SQL NULL values</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351560#M236309</link>
      <description>&lt;P&gt;Hi, I need to compare several csv columns with values from my db. To do so I use the LookupRecord with concat various csv columns and the corresponding concat of sql columns in the DatabaseRecordLookupService. This works fine as long as I do not have any NULL values in my db.&lt;/P&gt;&lt;P&gt;If there is a NULL value the Lookup Processor always routes those datasets to unmatched, as an empty string in the csv does not match the NULL values from the db.&lt;/P&gt;&lt;P&gt;What needs to be written in the corresponding csv column so that it matches the db NULL value?&lt;/P&gt;&lt;P&gt;I already tried to insert 'null', 'NULL' and 0 in the csv but it never matched the db value.&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 09:30:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351560#M236309</guid>
      <dc:creator>code</dc:creator>
      <dc:date>2022-09-06T09:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi Lookup CSV values with SQL NULL values</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351590#M236312</link>
      <description>&lt;P&gt;The CSV reader has a property name Null String that allows you to set the value that will appear in a CSV field to represent null.&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="JimHalfpenny_0-1662460934921.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35465i6B89AEC9CCC3821C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JimHalfpenny_0-1662460934921.png" alt="JimHalfpenny_0-1662460934921.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Try setting this when you read your CSV records. I've not tested whether this passes null to a SQL query, but using a literal value like "null" in your CSV data will be interpreted as a string.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 10:44:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351590#M236312</guid>
      <dc:creator>JimHalfpenny</dc:creator>
      <dc:date>2022-09-06T10:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi Lookup CSV values with SQL NULL values</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351600#M236317</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/99564"&gt;@code&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't think this is actually possible. Even if there was a way to enter a literal value of NULL for the lookup value, the controller service is probably comparing the lookup value with an "equals" operation (e.g. mytable.mykey = lookup_value) and in relational databases the comparison NULL = NULL is always evaluated to FALSE. (the only way to compare values with a NULL is to use the operator IS).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What you can try to do is to create a view on top of that table that converts NULLs to some string that you can use to compare to lookup values in NiFi. Then you can use the view name in the controller service configuration instead of the table name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CREATE VIEW v_mytable AS
SELECT
  NVL(mykey, '&amp;lt;NULL&amp;gt;') as key_without_nulls, *
FROM mytable&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Be aware of potential performance implications of this, since this could prevent existing table indexes from being used for lookups.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;André&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 11:30:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351600#M236317</guid>
      <dc:creator>araujo</dc:creator>
      <dc:date>2022-09-06T11:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi Lookup CSV values with SQL NULL values</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351621#M236319</link>
      <description>&lt;P&gt;Agreed, I did a quick test and null values in records return null when the lookup is done. As André says, querying column_value = null does not match a null value in the column as an IS NULL statement would. Ideally you should not have a key column which contains nulls or duplicate rows since this is going to unpredictable results.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 14:21:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351621#M236319</guid>
      <dc:creator>JimHalfpenny</dc:creator>
      <dc:date>2022-09-06T14:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi Lookup CSV values with SQL NULL values</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351667#M236333</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/100262"&gt;@JimHalfpenny&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/11191"&gt;@araujo&lt;/a&gt;&amp;nbsp;thanks both of you for your help!&lt;/P&gt;&lt;P&gt;The solution of creating a view with some kind of placeholders worked for me!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 07:34:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-Lookup-CSV-values-with-SQL-NULL-values/m-p/351667#M236333</guid>
      <dc:creator>code</dc:creator>
      <dc:date>2022-09-07T07:34:52Z</dc:date>
    </item>
  </channel>
</rss>

