Return-Path: X-Original-To: apmail-drill-issues-archive@minotaur.apache.org Delivered-To: apmail-drill-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0F1C518596 for ; Tue, 3 Nov 2015 23:11:28 +0000 (UTC) Received: (qmail 35686 invoked by uid 500); 3 Nov 2015 23:11:28 -0000 Delivered-To: apmail-drill-issues-archive@drill.apache.org Received: (qmail 35653 invoked by uid 500); 3 Nov 2015 23:11:28 -0000 Mailing-List: contact issues-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list issues@drill.apache.org Received: (qmail 35631 invoked by uid 99); 3 Nov 2015 23:11:27 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2015 23:11:27 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id D4C132C14E1 for ; Tue, 3 Nov 2015 23:11:27 +0000 (UTC) Date: Tue, 3 Nov 2015 23:11:27 +0000 (UTC) From: "Julian Hyde (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DRILL-4021) Cannot subract or add between two timestamps MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DRILL-4021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14988403#comment-14988403 ] Julian Hyde commented on DRILL-4021: ------------------------------------ I'll ask a rhetorical question: If you subtract two timestamps, what units would you expect the result to have? Milliseconds? Days? Standard SQL says that if you subtract two date-time values you need to say what type of interval you can back (e.g. an interval in seconds). Thus you must write {code}t2 - t1 second{code} or {code}t2 - t1 month to year{code}. Standard SQL does not allow you add two date-time values at all. What would you expect 2015-01-01 + 2015-01-01 to return? I suppose you could say 'a value twice as far from the 1970-01-01 epoch as 2015-01-01' but then you are assuming an epoch. If you want to add to a date-time value, add an interval. {code}date '2015-01-01' + interval '2' year{code} should work. So, this is not a bug. > Cannot subract or add between two timestamps > -------------------------------------------- > > Key: DRILL-4021 > URL: https://issues.apache.org/jira/browse/DRILL-4021 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Data Types > Reporter: Krystal > > The following subtraction between 2 now() function works: > select now() - now()from voter_hive limit 1; > +---------+ > | EXPR$0 | > +---------+ > | PT0S | > +---------+ > > However, the following queries fail: > select now() - create_time from voter_hive where voter_id=1; > Error: VALIDATION ERROR: From line 1, column 8 to line 1, column 26: Cannot apply '-' to arguments of type ' - '. Supported form(s): ' - ' > ' - ' > ' - ' > select create_time - cast('1997-02-12 15:18:31.072' as timestamp) from voter_hive where voter_id=1; > Error: VALIDATION ERROR: From line 1, column 8 to line 1, column 65: Cannot apply '-' to arguments of type ' - '. Supported form(s): ' - ' > ' - ' > ' - ' -- This message was sent by Atlassian JIRA (v6.3.4#6332)