<?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: Phoenix function in the Where clause in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170598#M25333</link>
    <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/627/asinghal.html" nodeid="627"&gt;@asinghal&lt;/A&gt; &amp;amp; &lt;A rel="user" href="https://community.cloudera.com/users/223/jelser.html" nodeid="223"&gt;@Josh Elser&lt;/A&gt; . The following query fixed it..&lt;/P&gt;&lt;P&gt;select count(*) from CDC WHERE "key" &amp;gt; TO_CHAR(TO_NUMBER(NOW())-600000,'#############');&lt;/P&gt;&lt;P&gt;Appreciate your quick help.&lt;/P&gt;&lt;P&gt;-Datta&lt;/P&gt;</description>
    <pubDate>Fri, 15 Apr 2016 23:27:05 GMT</pubDate>
    <dc:creator>dattatri_chandr</dc:creator>
    <dc:date>2016-04-15T23:27:05Z</dc:date>
    <item>
      <title>Phoenix function in the Where clause</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170593#M25328</link>
      <description>&lt;P&gt;We have a phoenix table with "key" as time in millisec. I am trying to get count of number of records for the last 10 minutes by using Phoenix functions in the where clause, but not going anywhere. It just returns the zero count.&lt;/P&gt;&lt;P&gt; Anyone tried functions on the where clause something like below ? &lt;/P&gt;&lt;P&gt;select count(*) from CDC where CDC."key" &amp;gt; TO_CHAR((TO_NUMBER(NOW())-600000);&lt;/P&gt;&lt;P&gt;-Datta&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 22:15:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170593#M25328</guid>
      <dc:creator>dattatri_chandr</dc:creator>
      <dc:date>2016-04-15T22:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Phoenix function in the Where clause</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170594#M25329</link>
      <description>&lt;P&gt;Can you share your table schema, please? Also, it might help you to do something like the following to help debug&lt;/P&gt;&lt;PRE&gt;select key, TO_CHAR(TO_NUMBER(NOW())-600000) from CDC;
&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Apr 2016 22:26:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170594#M25329</guid>
      <dc:creator>elserj</dc:creator>
      <dc:date>2016-04-15T22:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Phoenix function in the Where clause</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170595#M25330</link>
      <description>&lt;P&gt;yes , functions in where clause works perfectly.&lt;/P&gt;&lt;P&gt;I think to_char() will be giving epoch with commas&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 22:40:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170595#M25330</guid>
      <dc:creator>asinghal</dc:creator>
      <dc:date>2016-04-15T22:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Phoenix function in the Where clause</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170596#M25331</link>
      <description>&lt;P&gt;Hi Josh,
Thanks for the response. It works fine in the select query. I built the function by putting it in select query something like below.
0: jdbc:phoenix:lnxhdpdp07.smrcy.com,lnxhdpdp&amp;gt; select "key", TO_CHAR(TO_NUMBER(NOW())-600000) as TM from CDC LIMIT 5; &lt;/P&gt;&lt;P&gt;+------------------------------------------+-------------------+
|                   key                    |        TM         |
+------------------------------------------+-------------------+
| 1460067042710,EPT,26|T|Z978926||1        | 1,460,734,960,474 |
| 1460067042710,EPT,26|T|Z978926||8        | 1,460,734,960,474 |
| 1460067042711,EPT,26|T|Z978926||1        | 1,460,734,960,474 |
| 1460067042711,EPT,26|T|Z978926||8        | 1,460,734,960,474 |
| 1460067042712,EPT,26|T|Z978926||1        | 1,460,734,960,474 |
+------------------------------------------+-------------------+&lt;/P&gt;&lt;P&gt;Also works fine, If I put the hardcoded value in the function part of where clause ... 
0: jdbc:phoenix:lnxhdpdp07.smrcy.com,lnxhdpdp&amp;gt; SELECT COUNT(*) FROM CDC WHERE "key"&amp;gt; '1460734960474'; +------------------------------------------+
|                 COUNT(1)                 |
+------------------------------------------+
| 539753                                   |
+------------------------------------------+ Also tried putting it in "where (regexp_split(CDC."key",',')[1]) &amp;gt; TO_CHAR((TO_NUMBER(NOW())-60000)" didn't work.
DDL is as below :
DROP VIEW IF EXISTS CDC;
CREATE VIEW CDC
( 
"key" VARCHAR primary key
)
 default_column_family='d';&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 23:05:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170596#M25331</guid>
      <dc:creator>dattatri_chandr</dc:creator>
      <dc:date>2016-04-15T23:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Phoenix function in the Where clause</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170597#M25332</link>
      <description>&lt;PRE&gt;"where (regexp_split(CDC."key",',')[1]) &amp;gt; TO_CHAR((TO_NUMBER(NOW())-60000)"
&lt;/PRE&gt;&lt;P&gt;You want to be doing the regexp_split on the TO_CHAR side of that expression, not the key side. Like Ankit pointed out, TO_CHAR is putting the commas in the number while your key does not have commas.&lt;/P&gt;&lt;P&gt;However, a comma sorts before all of the numbers so I would have thought that you would get all records (instead of none). Still, I think I would try fixing your WHERE clause to make sure you comparing numbers without commas on both sides of the expression.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 23:13:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170597#M25332</guid>
      <dc:creator>elserj</dc:creator>
      <dc:date>2016-04-15T23:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Phoenix function in the Where clause</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170598#M25333</link>
      <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/627/asinghal.html" nodeid="627"&gt;@asinghal&lt;/A&gt; &amp;amp; &lt;A rel="user" href="https://community.cloudera.com/users/223/jelser.html" nodeid="223"&gt;@Josh Elser&lt;/A&gt; . The following query fixed it..&lt;/P&gt;&lt;P&gt;select count(*) from CDC WHERE "key" &amp;gt; TO_CHAR(TO_NUMBER(NOW())-600000,'#############');&lt;/P&gt;&lt;P&gt;Appreciate your quick help.&lt;/P&gt;&lt;P&gt;-Datta&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 23:27:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Phoenix-function-in-the-Where-clause/m-p/170598#M25333</guid>
      <dc:creator>dattatri_chandr</dc:creator>
      <dc:date>2016-04-15T23:27:05Z</dc:date>
    </item>
  </channel>
</rss>

