datetime - HiveQL, Hive SQL select date range -


It looks simple in SQL, but I'm having trouble using HiveQL with date range < P> I have a dataset like this:

  hive> Description of the log; Id string, ts string, ap_id int hive & gt; Choose log range from 5 * 1389 2014-10-05 13:57:01 12 1656 2014-10-06 03:57:59 15 1746 2014-10-06 10:58:25 19 1389 2014-10-09 08:57:01 12 1656 2014 -10-10 01:57:59 15   

My goal is to get a unique ID for the last 3 days. The best part is to read the current system time and get a unique ID of the last 3 days, but it is not sure where I should place "unix_timestamp ()". It is believed that log realtime has been recorded and today's date is in TS, I tried to use this query (first approach)

  hive> Select a different ID from the Log ID (TS) & gt; Date_sub (max (ts), 3) and to_date (ts) & lt; Maximum (ts); FAILED: Semantic Expression [Error 10025]: Line 1:45 The key is not expression in the group by 'ts'   

If I add a group like 'ts' below it then this error Prevents:

  hive & gt; HAVING to_date (ts) & gt; Select specific extensions from the pas_api_logs group. Date_sub (max (ts), 7) and to_date (ts) & lt; Maximum (ts); FAILED: Semantic Expression 1:47 SELECT DISTINCT and GROUP BY can not be in the same question. After several attempts after facing the error with Tocon 'TS, such a last vacancy was made [after the similar topic] [1]. [1].  
  Select different IDs (select * Log in Logs Logs (maximum (logs.ts) = to_date (logs.ts)) Union Select All * Log from log ( To_date (logs.ts) = date_sub (max (logs) ts), 1)) Select union all * Log in from log (to-date (logs.) = Date_sub (maximum (log. ST), 2) ));   

Apparently this does not work either, can someone put some light on it?

Using the statement, the necessary results can be obtained:

Select where DATEDIFF (from_inestime (Unix_timestamp ()), ts) & lt; = 3;

Hope it helps!

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -