impala-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [3/8] incubator-impala git commit: IMPALA-6225: Part 1: Query profile date-time strings should have ns precision.
Date Tue, 28 Nov 2017 18:41:10 GMT
IMPALA-6225: Part 1: Query profile date-time strings should have ns precision.

IMPALA-5599 changed the precision of query start and end time date-time
string representations to microseconds. This ended up breaking
compatibility with some API clients.

This patch restores the precision to nanosecond, even though the
timestamps themselves have only microsecond precision. Effectively,
what we end up doing is to zero-pad the fractional second part to
nine decimal places.

I have manually checked from the Impala debug web page that the start
and end times of queries have nanosecond precision:

    Start Time: 2017-11-20 14:59:01.954031000
    End Time: 2017-11-20 15:00:02.103735000

This is basically the same as how it was before. The following is taken
from a cluster running Impala 2.11:

    Start Time: 2017-11-20 14:17:52.198270000
    End Time: 2017-11-20 14:18:52.242868000

Test cases that inspect timestamps of Impala query profiles from the
debug web page will be introduced in a follow-on commit.

Change-Id: I2e124b9c7e0717b8dc2cdab46aea41d74c5f2fd0
Reviewed-on: http://gerrit.cloudera.org:8080/8611
Reviewed-by: Michael Ho <kwho@cloudera.com>
Tested-by: Impala Public Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/16d8dd58
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/16d8dd58
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/16d8dd58

Branch: refs/heads/master
Commit: 16d8dd580bf7175df3243d226d788ab0f7a25473
Parents: abd9b0e
Author: Zoram Thanga <zoram@cloudera.com>
Authored: Mon Nov 20 15:01:04 2017 -0800
Committer: Impala Public Jenkins <impala-public-jenkins@gerrit.cloudera.org>
Committed: Mon Nov 27 23:43:25 2017 +0000

----------------------------------------------------------------------
 be/src/service/client-request-state.cc | 10 ++++++++--
 be/src/service/impala-http-handler.cc  |  8 ++++----
 be/src/util/time.h                     |  4 ++--
 3 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/16d8dd58/be/src/service/client-request-state.cc
----------------------------------------------------------------------
diff --git a/be/src/service/client-request-state.cc b/be/src/service/client-request-state.cc
index 5d00d24..b925b5e 100644
--- a/be/src/service/client-request-state.cc
+++ b/be/src/service/client-request-state.cc
@@ -107,7 +107,10 @@ ClientRequestState::ClientRequestState(
     summary_profile_->AddInfoString("HiveServer2 Protocol Version",
         Substitute("V$0", 1 + session->hs2_version));
   }
-  summary_profile_->AddInfoString("Start Time", ToStringFromUnixMicros(start_time_us()));
+  // Certain API clients expect Start Time and End Time to be date-time strings
+  // of nanosecond precision, so we explicitly specify the precision here.
+  summary_profile_->AddInfoString("Start Time", ToStringFromUnixMicros(start_time_us(),
+      TimePrecision::Nanosecond));
   summary_profile_->AddInfoString("End Time", "");
   summary_profile_->AddInfoString("Query Type", "N/A");
   summary_profile_->AddInfoString("Query State", PrintQueryState(query_state_));
@@ -566,7 +569,10 @@ void ClientRequestState::Done() {
 
   unique_lock<mutex> l(lock_);
   end_time_us_ = UnixMicros();
-  summary_profile_->AddInfoString("End Time", ToStringFromUnixMicros(end_time_us()));
+  // Certain API clients expect Start Time and End Time to be date-time strings
+  // of nanosecond precision, so we explicitly specify the precision here.
+  summary_profile_->AddInfoString("End Time", ToStringFromUnixMicros(end_time_us(),
+      TimePrecision::Nanosecond));
   query_events_->MarkEvent("Unregister query");
 
   // Update result set cache metrics, and update mem limit accounting before tearing

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/16d8dd58/be/src/service/impala-http-handler.cc
----------------------------------------------------------------------
diff --git a/be/src/service/impala-http-handler.cc b/be/src/service/impala-http-handler.cc
index d746ff2..33c5e73 100644
--- a/be/src/service/impala-http-handler.cc
+++ b/be/src/service/impala-http-handler.cc
@@ -292,12 +292,12 @@ void ImpalaHttpHandler::QueryStateToJson(const ImpalaServer::QueryStateRecord&
r
       document->GetAllocator());
   value->AddMember("stmt_type", stmt_type, document->GetAllocator());
 
-  Value start_time(ToStringFromUnixMicros(record.start_time_us).c_str(),
-      document->GetAllocator());
+  Value start_time(ToStringFromUnixMicros(record.start_time_us,
+      TimePrecision::Nanosecond).c_str(), document->GetAllocator());
   value->AddMember("start_time", start_time, document->GetAllocator());
 
-  Value end_time(ToStringFromUnixMicros(record.end_time_us).c_str(),
-      document->GetAllocator());
+  Value end_time(ToStringFromUnixMicros(record.end_time_us,
+      TimePrecision::Nanosecond).c_str(), document->GetAllocator());
   value->AddMember("end_time", end_time, document->GetAllocator());
 
   // record.end_time_us might still be zero if the query is not yet done

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/16d8dd58/be/src/util/time.h
----------------------------------------------------------------------
diff --git a/be/src/util/time.h b/be/src/util/time.h
index d636183..cef14c8 100644
--- a/be/src/util/time.h
+++ b/be/src/util/time.h
@@ -104,9 +104,9 @@ std::string ToUtcStringFromUnixMicros(int64_t us,
     TimePrecision p = TimePrecision::Microsecond);
 
 /// Convenience function to convert the current time, derived from UnixMicros(),
-/// to a date-time string in the local time zone.
+/// to a date-time string in the local time zone, padded to nanosecond precision.
 inline std::string CurrentTimeString() {
-  return ToStringFromUnixMicros(UnixMicros());
+  return ToStringFromUnixMicros(UnixMicros(), TimePrecision::Nanosecond);
 }
 } // namespace impala
 #endif


Mime
View raw message