<?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 compare float datatype columns with string value in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-compare-float-datatype-columns-with-string-value/m-p/218479#M180380</link>
    <description>&lt;P&gt;Anyways, your answer has given an approach to solve this. Shall accept your answer.&lt;/P&gt;</description>
    <pubDate>Fri, 05 May 2017 13:54:45 GMT</pubDate>
    <dc:creator>harkarekunal10</dc:creator>
    <dc:date>2017-05-05T13:54:45Z</dc:date>
    <item>
      <title>How to compare float datatype columns with string value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-compare-float-datatype-columns-with-string-value/m-p/218476#M180377</link>
      <description>&lt;P&gt;I have a table `exchangedata` in hive with the following columns&lt;/P&gt;&lt;PRE&gt;day STRING
euro float
yen float
dollar float&lt;/PRE&gt;&lt;P&gt;and the tasks to perform on this table are&lt;/P&gt;&lt;P&gt;1) Load data from '/user/practiceuser/exchangedata.csv' in HDFS into `exchangedata` table&lt;/P&gt;&lt;P&gt;2) Remove All the rows where value of euro, yen and dollar is equal to string '#N/A'&lt;/P&gt;&lt;P&gt;3) Load the result into `exchangedata` table&lt;/P&gt;&lt;P&gt;My Solution -------&lt;/P&gt;&lt;P&gt;As the `exchangedata` table is not  in ORC format and is also not clustered(For DELETE query), I created a temporary table `exchange_temp` with the same columns and then used below query to insert data into `exchangedata`&lt;/P&gt;&lt;PRE&gt;INSERT INTO TABLE exchangedata SELECT day,euro,yen,dollar FROM exchange_temp WHERE euro != '#N/A' AND yen != '#N/A' AND dollar != '#N/A';
&lt;/PRE&gt;&lt;P&gt;But after executing this query I am not getting any row in output.
My question is how can I compare float datatype column with String '#N/A'?&lt;/P&gt;&lt;P&gt;The data in the CSV file looks like this&lt;/P&gt;&lt;PRE&gt;FRIDAY,1.234,2.456,1.059&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 May 2017 12:35:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-compare-float-datatype-columns-with-string-value/m-p/218476#M180377</guid>
      <dc:creator>harkarekunal10</dc:creator>
      <dc:date>2017-05-03T12:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare float datatype columns with string value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-compare-float-datatype-columns-with-string-value/m-p/218477#M180378</link>
      <description>&lt;P&gt;
	That is always a night mare in JAVA based tools. Hive relies on JAVA (plus SQL) so it respects the IEEE standard for number semantics. That means especially NaN (not a number) values in float columns are a tricky thing.&lt;/P&gt;&lt;P&gt;
	First of all: Have you tested what is returned for the '#N/A' columns when you do a select? I guess it is rather 'NaN' than '#N/A'.&lt;/P&gt;&lt;P&gt;
	So after testing the return value, I would suggest to test two approaches. Either try to use cast():&lt;/P&gt;&lt;PRE&gt;	cast(dollar as String) &amp;lt;&amp;gt;'NaN' &lt;/PRE&gt;&lt;P&gt;
	(because all possible NaN values are displayed as "NaN" even if they are not strictly "equal" in the arithmetical sense)&lt;/P&gt;&lt;P&gt;
	or do the old trick and test the value of the column to fit a mathematical operation like e.g. &lt;/P&gt;&lt;PRE&gt;dollar +1.0 &amp;gt; dollar&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 May 2017 15:53:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-compare-float-datatype-columns-with-string-value/m-p/218477#M180378</guid>
      <dc:creator>pgreiff</dc:creator>
      <dc:date>2017-05-03T15:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare float datatype columns with string value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-compare-float-datatype-columns-with-string-value/m-p/218478#M180379</link>
      <description>&lt;P&gt;Thanks for your replay Peter. Actually, this was EXACTLY the question asked during my certification exam and the column was a string '#N/A'. I didn't know about the cast() function, so I was directly comparing float datatype to a string value using '!='. Also the SELECT wasn't returning any rows.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 13:52:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-compare-float-datatype-columns-with-string-value/m-p/218478#M180379</guid>
      <dc:creator>harkarekunal10</dc:creator>
      <dc:date>2017-05-05T13:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare float datatype columns with string value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-compare-float-datatype-columns-with-string-value/m-p/218479#M180380</link>
      <description>&lt;P&gt;Anyways, your answer has given an approach to solve this. Shall accept your answer.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 13:54:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-compare-float-datatype-columns-with-string-value/m-p/218479#M180380</guid>
      <dc:creator>harkarekunal10</dc:creator>
      <dc:date>2017-05-05T13:54:45Z</dc:date>
    </item>
  </channel>
</rss>

