- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Impala timestamp diff functionality
- Labels:
-
Apache Impala
Created on ‎04-04-2014 10:10 AM - edited ‎09-16-2022 01:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the best way to do a diff on timestamp fields in Impala version 1.2.3 where the difference in milliseconds is required?
Here is my query-
select a.session_key,a.ani,a.event_timestamp "event_start_timetsamp",b.event_timestamp "event_end_timestamp"
from nuance_ivr_logs a, nuance_ivr_logs b
where
a.session_key='{134E1EF7-3A8E-4FA8-A944-89367DEA8FB7}'
and a.session_key=b.session_key
and a.ani=b.ani
and a.event_type='SWIclst' and a.event_attribute_seq=1
and b.event_type='SWIclnd' and a.event_attribute_seq=1;
+----------------------------------------+------------+-------------------------------+-------------------------------+
| session_key | ani | event_start_timetsamp | event_end_timestamp |
+----------------------------------------+------------+-------------------------------+-------------------------------+
| {134E1EF7-3A8E-4FA8-A944-89367DEA8FB7} | xxxxxxxx | 2013-12-17 17:59:58.677000000 | 2013-12-17 18:02:51.239000000 |
+----------------------------------------+------------+-------------------------------+-------------------------------+
I need to add a column for event_duration, which is the diff of event_end_timestamp and event_start_timestamp.
Thanks.
Created ‎05-04-2014 12:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd imagine something such as:
unix_timestamp(to_date(event_end_timestamp)) - unix_timestamp(to_date(event_start_timetsamp))
Should give you an bigint return of the number of milliseconds.
