From 65032f0c44f9e61472917998228a50a8deaa64aa Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Fri, 8 Nov 2024 09:56:07 +0100 Subject: [PATCH] Make arrow.flight.Timestamp truely nanoseconds precision --- cpp/src/arrow/flight/flight_internals_test.cc | 18 ++++++------------ cpp/src/arrow/flight/types.h | 3 ++- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/cpp/src/arrow/flight/flight_internals_test.cc b/cpp/src/arrow/flight/flight_internals_test.cc index 3f233cb7b74e5..ab2f8c7830786 100644 --- a/cpp/src/arrow/flight/flight_internals_test.cc +++ b/cpp/src/arrow/flight/flight_internals_test.cc @@ -184,12 +184,9 @@ TEST(FlightTypes, FlightDescriptor) { TEST(FlightTypes, FlightEndpoint) { ASSERT_OK_AND_ASSIGN(auto location1, Location::ForGrpcTcp("localhost", 1024)); ASSERT_OK_AND_ASSIGN(auto location2, Location::ForGrpcTls("localhost", 1024)); - // 2023-06-19 03:14:06.004330100 - // We must use microsecond resolution here for portability. - // std::chrono::system_clock::time_point may not provide nanosecond - // resolution on some platforms such as Windows. + // 2023-06-19 03:14:06.004339123 const auto expiration_time_duration = - std::chrono::seconds{1687144446} + std::chrono::nanoseconds{4339000}; + std::chrono::seconds{1687144446} + std::chrono::nanoseconds{4339123}; Timestamp expiration_time( std::chrono::duration_cast(expiration_time_duration)); std::vector values = { @@ -210,7 +207,7 @@ TEST(FlightTypes, FlightEndpoint) { " locations=[] " "expiration_time=null app_metadata='DEADBEEF'>", " locations=[] " - "expiration_time=2023-06-19 03:14:06.004339000 app_metadata=''>", + "expiration_time=2023-06-19 03:14:06.004339123 app_metadata=''>", " locations=" "[grpc+tcp://localhost:1024] expiration_time=null app_metadata=''>", " locations=" @@ -271,12 +268,9 @@ TEST(FlightTypes, PollInfo) { auto desc = FlightDescriptor::Command("foo"); auto endpoint = FlightEndpoint{Ticket{"foo"}, {}, std::nullopt, ""}; auto info = MakeFlightInfo(schema, desc, {endpoint}, -1, 42, true, ""); - // 2023-06-19 03:14:06.004330100 - // We must use microsecond resolution here for portability. - // std::chrono::system_clock::time_point may not provide nanosecond - // resolution on some platforms such as Windows. + // 2023-06-19 03:14:06.004339123 const auto expiration_time_duration = - std::chrono::seconds{1687144446} + std::chrono::nanoseconds{4339000}; + std::chrono::seconds{1687144446} + std::chrono::nanoseconds{4339123}; Timestamp expiration_time( std::chrono::duration_cast(expiration_time_duration)); std::vector values = { @@ -292,7 +286,7 @@ TEST(FlightTypes, PollInfo) { "progress=null expiration_time=null>", " " - "progress=0.1 expiration_time=2023-06-19 03:14:06.004339000>", + "progress=0.1 expiration_time=2023-06-19 03:14:06.004339123>", "", }; diff --git a/cpp/src/arrow/flight/types.h b/cpp/src/arrow/flight/types.h index b6309d0af2a71..8b612bd55ce91 100644 --- a/cpp/src/arrow/flight/types.h +++ b/cpp/src/arrow/flight/types.h @@ -80,7 +80,8 @@ class FlightServerBase; /// > all minutes are 60 seconds long, i.e. leap seconds are "smeared" /// > so that no leap second table is needed for interpretation. Range /// > is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. -using Timestamp = std::chrono::system_clock::time_point; +using Timestamp = + std::chrono::time_point; /// \brief A Flight-specific status code. Used to encode some /// additional status codes into an Arrow Status.