You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "eugen yushin (JIRA)" <ji...@apache.org> on 2018/11/26 09:18:00 UTC

[jira] [Created] (IMPALA-7885) Create function to convert to ts from unix millis

eugen yushin created IMPALA-7885:
------------------------------------

             Summary: Create function to convert to ts from unix millis
                 Key: IMPALA-7885
                 URL: https://issues.apache.org/jira/browse/IMPALA-7885
             Project: IMPALA
          Issue Type: Improvement
            Reporter: eugen yushin


There're several functions like `from_unixtime`/`unix_micros_to_utc_timestamp`/`to_timestamp` in Impala which accepts seconds and nanos, but none of them works with millis.

At the same time, Impala already has all necessary utility methods to add such a functionality:
[https://github.com/apache/impala/blob/master/be/src/runtime/timestamp-value.inline.h#L54]
{code}
inline TimestampValue TimestampValue::UtcFromUnixTimeMillis(int64_t unix_time_millis) {
 return UtcFromUnixTimeTicks<MILLIS_PER_SEC>(unix_time_millis);
}
{code}
https://github.com/apache/impala/blob/master/be/src/exprs/timestamp-functions-ir.cc#L141
{code}
TimestampVal TimestampFunctions::UnixMicrosToUtcTimestamp(FunctionContext* context,
    const BigIntVal& unix_time_micros) {
  if (unix_time_micros.is_null) return TimestampVal::null();
  TimestampValue tv = TimestampValue::UtcFromUnixTimeMicros(unix_time_micros.val);
  TimestampVal result;
  tv.ToTimestampVal(&result);
  return result;
}
{code}

It would be better to have Unix millis to timestamp conversion function as buit-in functionality to prevent from:
- creating cumbersome 'aliases' like:
{code}
select unix_micros_to_utc_timestamp(1513895588243 * 1000)
{code}
or
http://community.cloudera.com/t5/Interactive-Short-cycle-SQL/Why-not-from-unixtime-function-handles-an-unix-timestamp-in/m-p/63182#M3969
{code}
select cast(1513895588243 div 1000 as timestamp) + interval (1513895588243 % 1000) milliseconds;
{code}
- writing relatively slow udfs in java



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org