Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 067C4200D31 for ; Sat, 21 Oct 2017 05:13:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 04FC3160BED; Sat, 21 Oct 2017 03:13:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4AFD8160BCB for ; Sat, 21 Oct 2017 05:13:22 +0200 (CEST) Received: (qmail 9244 invoked by uid 500); 21 Oct 2017 03:13:21 -0000 Mailing-List: contact reviews-help@impala.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@impala.incubator.apache.org Received: (qmail 9233 invoked by uid 99); 21 Oct 2017 03:13:21 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Oct 2017 03:13:21 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 0AB8F180817 for ; Sat, 21 Oct 2017 03:13:19 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.362 X-Spam-Level: ** X-Spam-Status: No, score=2.362 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, RDNS_DYNAMIC=0.363, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id N0bPx90WM3AX for ; Sat, 21 Oct 2017 03:13:17 +0000 (UTC) Received: from ip-10-146-233-104.ec2.internal (ec2-75-101-130-251.compute-1.amazonaws.com [75.101.130.251]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 677705FCD3 for ; Sat, 21 Oct 2017 03:13:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ip-10-146-233-104.ec2.internal (8.14.4/8.14.4) with ESMTP id v9L3DEK9021707; Sat, 21 Oct 2017 03:13:14 GMT Message-Id: <201710210313.v9L3DEK9021707@ip-10-146-233-104.ec2.internal> X-Gerrit-PatchSet: 18 Date: Sat, 21 Oct 2017 03:13:14 +0000 From: "Impala Public Jenkins (Code Review)" To: Csaba Ringhofer , impala-cr@cloudera.com, reviews@impala.incubator.apache.org X-Gerrit-MessageType: merged Subject: =?UTF-8?Q?=5BImpala-ASF-CR=5D_IMPALA-5664=3A_Unix_time_to_timestamp_conversions_may_crash_Impala=0A?= X-Gerrit-Change-Id: I77b2f6284d3a597f57e61c17a67c959eff9e38ff X-Gerrit-Change-Number: 7954 X-Gerrit-ChangeURL: X-Gerrit-Commit: 41f0c6a5a6be887fbe42ae338274096c27090af6 In-Reply-To: References: Reply-To: impala-cr@cloudera.com, csringhofer@cloudera.com, reviews@impala.incubator.apache.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.14.2 Content-Type: multipart/alternative; boundary="PuncPpwbxxQ="; charset=UTF-8 archived-at: Sat, 21 Oct 2017 03:13:23 -0000 --PuncPpwbxxQ= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Impala Public Jenkins has submitted this change and it was merged=2E ( http= ://gerrit=2Ecloudera=2Eorg:8080/7954 ) Change subject: IMPALA-5664: Unix t= ime to timestamp conversions may crash Impala =2E=2E=2E=2E=2E=2E=2E=2E=2E= =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E= =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E= =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E IMPALA-5664: Unix time to timestamp conv= ersions may crash Impala TimestampValue::FromSubsecondUnixTime() and UtcFr= omUnixTimeMicros() are incorrect only in case of the last second of 1399, b= ecause these sub-second values are rounded first towards 1400-01-01 00:00:0= 0, which is accepted as a valid date, and the sub-second part is subtracted= afterwards, leading to a date outside the valid interval=2E The maximum ca= se, 9999-12-31 59:59:59 is a bit different, because as I understand, with n= anosecond precision posix times, the maximum value is actually 10000-01-01= =2E 00:00:00 minus 1 nanosec=2E TimestampValue::FromUnixTimeNanos() can cr= eate problematic TimestampValues both <1400 and 10000<=3D=2E These timesta= mps can cause problems, because most code assumes that if HasDate/HasTime i= s true, then it really is a valid timestamp=2E To fix this, the posix time= s are checked in the constructor of TimestampValue, and if it is outside th= e valid interval,both time_ and date_ are set to not_a_date_time=2E Test: = select cast(-17987443200-0=2E1 as timestamp); This query no longer crashes,= but returns NULL, similarly to other < 1400 timestamps=2E Change-Id: I77b= 2f6284d3a597f57e61c17a67c959eff9e38ff Reviewed-on: http://gerrit=2Ecloudera= =2Eorg:8080/7954 Reviewed-by: Lars Volker Tested-by: Im= pala Public Jenkins --- M be/src/exec/parquet-column-readers=2Ecc M be/src/= exec/parquet-column-stats=2Einline=2Eh M be/src/exprs/expr-test=2Ecc M be/s= rc/exprs/timestamp-functions-ir=2Ecc M be/src/runtime/timestamp-test=2Ecc M= be/src/runtime/timestamp-value=2Ecc M be/src/runtime/timestamp-value=2Eh M= testdata/workloads/functional-query/queries/QueryTest/exprs=2Etest 8 files= changed, 146 insertions(+), 10 deletions(-) Approvals: Lars Volker: Loo= ks good to me, approved Impala Public Jenkins: Verified -- To view, vis= it http://gerrit=2Ecloudera=2Eorg:8080/7954 To unsubscribe, visit http://ge= rrit=2Ecloudera=2Eorg:8080/settings Gerrit-Project: Impala-ASF Gerrit-Bran= ch: master Gerrit-MessageType: merged Gerrit-Change-Id: I77b2f6284d3a597f57= e61c17a67c959eff9e38ff Gerrit-Change-Number: 7954 Gerrit-PatchSet: 18 Gerri= t-Owner: Csaba Ringhofer Gerrit-Reviewer: Alex= Behm Gerrit-Reviewer: Csaba Ringhofer Gerrit-Reviewer: Dan Hecht Ge= rrit-Reviewer: Impala Public Jenkins Gerrit-Reviewer: Lars Volker --PuncPpwbxxQ=--