Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have figured out a work-around, and I'll share that with those of you searching for a solution. But first, it's obvious to me that Teradata's handling of NaN floating point values is incomplete and any behavior I've stumbled into figuring out is likely unintentional and inconsistent across different versions. So I offer the following free advice, with no guarantees, promises, or liabilities of any kind. Caveat emptor.</p> <p>After drilling down into the data, I find that if I CAST the FLOAT value to a VARCHAR(50), the NaN values come out as a string of 22 asterisks (<code>**********************</code>). I can cast to a VARCHAR(1) instead, and the NaN comes out as a single asterisk (<code>*</code>). That comparison isn't that bad.</p> <pre><code>SELECT SUM(VAL**2) FROM DTM WHERE NOT CAST (VAL AS VARCHAR(1)) = '*' AND ABS(VAL) &lt; 1.0e+21 </code></pre> <p>I'll note two things.</p> <p>First, my original desire of "NOT ABS(VAL) > 1.0e+21" on my version of Teradata seems to get converted to "ABS(VAL) &lt;= 1.0e+21" under the covers. This (sometimes) fails because of the equality potion of the comparison -- error [2651], "Operation Error computing expression involving VAL." I'm assuming that the conversion from "NOT >" to "&lt;=" is happening, because "NOT ABS(VAL) >= 1.0e+21" works fine (but looks ugly). Using "ABS(VAL) &lt; 1.0e+21" works just fine and captures the need.</p> <p>Second, while I can't reproduce it consistently, I have examples in my history where "ABS(VAL) &lt;= 1.0e+21" does effectively screen out NaN, some where it doesn't, and some where it fails with [2651] (see above), yet the SQL and the data in the tables were identical. The only conclusion I can come to is that Teradata is inconsistent in how it evaluates the comparison when NaN is involved (or it thinks it might be). It's possible that different amps are handling it differently, but I don't know for sure. That said, the above two comparisons in the where clause consistently and effectively screen out the Inf and NaN values.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload