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 3DDF2200BA4 for ; Sat, 1 Oct 2016 03:56:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3CB24160AD9; Sat, 1 Oct 2016 01:56: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 454E9160AEE for ; Sat, 1 Oct 2016 03:56:22 +0200 (CEST) Received: (qmail 97247 invoked by uid 500); 1 Oct 2016 01:56:21 -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 96912 invoked by uid 99); 1 Oct 2016 01:56:21 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Oct 2016 01:56:21 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id D64B42C2A69 for ; Sat, 1 Oct 2016 01:56:20 +0000 (UTC) Date: Sat, 1 Oct 2016 01:56:20 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DRILL-4864) Add ANSI format for date/time functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sat, 01 Oct 2016 01:56:23 -0000 [ https://issues.apache.org/jira/browse/DRILL-4864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15537662#comment-15537662 ] ASF GitHub Bot commented on DRILL-4864: --------------------------------------- Github user gparai commented on a diff in the pull request: https://github.com/apache/drill/pull/581#discussion_r81438289 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java --- @@ -408,6 +411,12 @@ private LogicalExpression getDrillFunctionFromOptiqCall(RexCall call) { return first; } + } else if (functionName.equals("to_date") || functionName.equals("to_time") || functionName.equals("to_timestamp")) { + // convert ansi date format string to joda according to session option + OptionManager om = this.context.getPlannerSettings().getOptions(); + if(ToDateFormats.valueOf(om.getOption(ExecConstants.TO_DATE_FORMAT).string_val.toUpperCase()).equals(ToDateFormats.ANSI)) { --- End diff -- if ( > Add ANSI format for date/time functions > --------------------------------------- > > Key: DRILL-4864 > URL: https://issues.apache.org/jira/browse/DRILL-4864 > Project: Apache Drill > Issue Type: Improvement > Affects Versions: 1.8.0 > Reporter: Serhii Harnyk > Assignee: Gautam Kumar Parai > Labels: doc-impacting > Fix For: 1.9.0 > > > The TO_DATE() is exposing the Joda string formatting conventions into the SQL layer. This is not following SQL conventions used by ANSI and many other database engines on the market. > Add new UDF "ansi_to_joda(string)", that takes string that represents ANSI datetime format and returns string that represents equal Joda format. > Add new session option "drill.exec.fn.to_date_format" that can be one of two values - "JODA"(default) and "ANSI". > If option is set to "JODA" queries with to_date() function would work in usual way. > If option is set to "ANSI" second argument would be wrapped with ansi_to_joda() function, that allows user to use ANSI datetime format > Wrapping is used in to_date(), to_time() and to_timestamp() functions. > Table of joda and ansi patterns which may be replaced > || Pattern name || Ansi format || JodaTime format > | Full name of day | day | EEEE > | Day of year | ddd | D > | Day of month | dd | d > | Day of week | d | e > | Name of month | month | MMMM > | Abr name of month | mon | MMM > | Full era name | ee | G > | Name of day | dy | E > | Time zone | tz | TZ > | Hour 12 | hh | h > | Hour 12 | hh12 | h > | Hour 24 | hh24 | H > | Minute of hour | mi | m > | Second of minute | ss | s > | Millisecond of minute | ms | S > | Week of year | ww | w > | Month | mm | MM > | Halfday am | am | aa > | Halfday pm | pm | aa > | ref. | https://www.postgresql.org/docs/8.2/static/functions-formatting.html | http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html | > Table of ansi pattern modifiers, which may be deleted from string > || Description || Pattern || > | fill mode (suppress padding blanks and zeroes) | fm | > | fixed format global option (see usage notes) | fx | > | translation mode (print localized day and month names based on lc_messages) | tm | > | spell mode (not yet implemented) | sp | > | ref. | https://www.postgresql.org/docs/8.2/static/functions-formatting.html | -- This message was sent by Atlassian JIRA (v6.3.4#6332)