Csaba Ringhofer has posted comments on this change. ( http://gerrit.cloudera.org:8080/11919 )
Change subject: IMPALA-5031: signed overflow in TimestampValue ...................................................................... Patch Set 1: (1 comment) I have two concerns with the solution: 1. performance - convert-timestamp-benchmark.cc has a test for this function, can you run it in release mode? I would call this function medium performance critical - it is called in decimal->timestamp conversion, so it is not used in most queries, but has the potential to dominate some specific queries. 2. readability - the change adds some complexity that I would prefer to avoid if possible, see my comment in line 66 for ideas. http://gerrit.cloudera.org:8080/#/c/11919/1/be/src/runtime/timestamp-value.inline.h File be/src/runtime/timestamp-value.inline.h: http://gerrit.cloudera.org:8080/#/c/11919/1/be/src/runtime/timestamp-value.inline.h@66 PS1, Line 66: int64_t nanos Some explanation for the reason why I did not care about overflow when I last touched this code: nanos makes sense in the +-10^9 range, and all (non-test) callers pass int32/uint32, so the range we can get here is not much larger than that (~ -2 to 4 sec). This means that overflow of unix_time is only possible near the min/max value representable on 64 bits, which is far outside the valid range of timestamps, so the overflow can only change an invalid timestamp to another invalid timestamp. I would prefer to avoid the overflow by changing the interface to handle nanos only in the -999'999'999 .. + 999'999'999 range, and treat other values as invalid timestamps. This would mean that unix_time would be affected only in the negative case. The only caller code that would need to be changed are tests and timestamp-test.cc. Another way to do this is to change the valid range to 0 .. 999'999'999, which would make this function even simpler, but would need some changes in DecimalOperators::ConvertToTimestampVal. -- To view, visit http://gerrit.cloudera.org:8080/11919 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Iaad158e6634314a5690a43a0cc04426c1aba8f41 Gerrit-Change-Number: 11919 Gerrit-PatchSet: 1 Gerrit-Owner: Jim Apple <[email protected]> Gerrit-Reviewer: Csaba Ringhofer <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Comment-Date: Mon, 19 Nov 2018 13:34:26 +0000 Gerrit-HasComments: Yes
