Return-Path: X-Original-To: apmail-hive-user-archive@www.apache.org Delivered-To: apmail-hive-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 17C129BA3 for ; Tue, 13 Mar 2012 17:47:45 +0000 (UTC) Received: (qmail 39676 invoked by uid 500); 13 Mar 2012 17:47:44 -0000 Delivered-To: apmail-hive-user-archive@hive.apache.org Received: (qmail 39638 invoked by uid 500); 13 Mar 2012 17:47:44 -0000 Mailing-List: contact user-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hive.apache.org Delivered-To: mailing list user@hive.apache.org Received: (qmail 39630 invoked by uid 99); 13 Mar 2012 17:47:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Mar 2012 17:47:44 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kwiley@keithwiley.com designates 69.93.164.27 as permitted sender) Received: from [69.93.164.27] (HELO gateway15.websitewelcome.com) (69.93.164.27) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Mar 2012 17:47:36 +0000 Received: by gateway15.websitewelcome.com (Postfix, from userid 5007) id 1DF638CC82E6; Tue, 13 Mar 2012 12:47:14 -0500 (CDT) Received: from gator542.hostgator.com (gator542.hostgator.com [74.54.187.114]) by gateway15.websitewelcome.com (Postfix) with ESMTP id 1292D8CC82AB for ; Tue, 13 Mar 2012 12:47:14 -0500 (CDT) Received: from [24.19.6.8] (port=48682 helo=[192.168.10.2]) by gator542.hostgator.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1S7VoX-0003ZX-C6 for user@hive.apache.org; Tue, 13 Mar 2012 12:47:13 -0500 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: order by date From: Keith Wiley In-Reply-To: <4CED3A5A427FF34BAEE89C98D64D336D1F89D7FADB@SM-FLOR-VXMB06B.wdw.disney.com> Date: Tue, 13 Mar 2012 10:47:12 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <092C1FB3-CC43-48D6-9ADB-5A238A039DA5@keithwiley.com> References: <3DA234E7-77C8-493C-B663-66960C88EC68@keithwiley.com> <4CED3A5A427FF34BAEE89C98D64D336D1F89D7FA65@SM-FLOR-VXMB06B.wdw.disney.com> <8174D6C6-A502-4F56-A093-7F352756EAD8@keithwiley.com> <4CED3A5A427FF34BAEE89C98D64D336D1F89D7FADB@SM-FLOR-VXMB06B.wdw.disney.com> To: user@hive.apache.org X-Mailer: Apple Mail (2.1084) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator542.hostgator.com X-AntiAbuse: Original Domain - hive.apache.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - keithwiley.com X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: c-24-19-6-8.hsd1.wa.comcast.net ([192.168.10.2]) [24.19.6.8]:48682 X-Source-Auth: kwiley+keithwiley.com X-Email-Count: 4 X-Source-Cap: a2J3aWxleTtrYndpbGV5O2dhdG9yNTQyLmhvc3RnYXRvci5jb20= X-Virus-Checked: Checked by ClamAV on apache.org I see how I misled you, sorry. I wasn't implying that my csv data is = cleanly represented in yyyy-MM-dd format. I was just asking = syntactically how to use date functions in HiveQL because I hadn't found = any examples and I used yyyy-MM-dd in my example. The dates in my csv = tables are often in "American" format, month first without leading = zeroes, e.g., "3/31/2012 7:00". The lack of leading zeroes and the = unsortabled date format make the dates difficult to work with. I was = thinking I could use the date functions with some other format to sort = them (I guess it would be "M/d/yyyy h:mm" or something like that). I admit, I didn't actually go to the trouble of providing the correct = pattern string in my earlier post, I was focused on the HiveQL syntax in = that post, not the precise date pattern given to the date function. So yeah, I'm still trying to determine the best way to sort queries = against the date-time columns. One option is to read/write the entire = tables with a date conversion to a lexicographic format. Another option = -- my original question in this thread -- was how I might use hive's = date functions at the time a query is performed. What do you think is the best way to deal with this? Thanks. On Mar 13, 2012, at 10:35 , Tucker, Matt wrote: > I'm a bit confused. It sounds like you're already storing your dates = as strings in a 'yyyy-mm-dd' format. In that case, you can just sort by = dateColName. There's no issue with using UNIX_TIMESTAMP() in the order = by clause, as it outputs integer values. >=20 > Most of the date functions in hive take arguments in string format, = with a few functions that will translate between unix timestamps and = datetime strings. >=20 > Matt Tucker = __________________________________________________________________________= ______ Keith Wiley kwiley@keithwiley.com keithwiley.com = music.keithwiley.com "I do not feel obliged to believe that the same God who has endowed us = with sense, reason, and intellect has intended us to forgo their use." -- Galileo Galilei = __________________________________________________________________________= ______