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 0D45D200C72 for ; Thu, 27 Apr 2017 18:18:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0C07F160B98; Thu, 27 Apr 2017 16:18:14 +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 53ED0160BB2 for ; Thu, 27 Apr 2017 18:18:13 +0200 (CEST) Received: (qmail 86515 invoked by uid 500); 27 Apr 2017 16:18:12 -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 86469 invoked by uid 99); 27 Apr 2017 16:18:11 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Apr 2017 16:18:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 3D61F1A7A59 for ; Thu, 27 Apr 2017 16:18:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.201 X-Spam-Level: X-Spam-Status: No, score=-99.201 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id gPs6ZWm952zQ for ; Thu, 27 Apr 2017 16:18:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 4200F5FC1C for ; Thu, 27 Apr 2017 16:18:06 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7E609E0AF9 for ; Thu, 27 Apr 2017 16:18:05 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 6885021DE0 for ; Thu, 27 Apr 2017 16:18:04 +0000 (UTC) Date: Thu, 27 Apr 2017 16:18:04 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DRILL-5419) Calculate return string length for literals & some string functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 27 Apr 2017 16:18:14 -0000 [ https://issues.apache.org/jira/browse/DRILL-5419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15986926#comment-15986926 ] ASF GitHub Bot commented on DRILL-5419: --------------------------------------- Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/819#discussion_r113605880 --- Diff: common/src/main/java/org/apache/drill/common/types/Types.java --- @@ -399,7 +403,13 @@ public static boolean isFixedWidthType(final MajorType type) { } - public static boolean isStringScalarType(final MajorType type) { + /** + * Checks is given major type is string scalar type. --- End diff -- is --> if > Calculate return string length for literals & some string functions > ------------------------------------------------------------------- > > Key: DRILL-5419 > URL: https://issues.apache.org/jira/browse/DRILL-5419 > Project: Apache Drill > Issue Type: Bug > Affects Versions: 1.9.0 > Reporter: Arina Ielchiieva > Assignee: Arina Ielchiieva > Attachments: version_with_cast.JPG > > > Though Drill is schema-less and cannot determine in advance what the length of the column should be but if query has an explicit type/length specified, Drill should return correct column length. > For example, JDBC / ODBC Driver is ALWAYS returning 64K as the length of a varchar or char even if casts are applied. > Changes: > *LITERALS* > String literals length is the same as actual literal length. > Example: for 'aaa' return length is 3. > *CAST* > Return length is the one indicated in cast expression. This also applies when user has created view where each string columns was casted to varchar with some specific length. > This length will be returned to the user without need to apply cast one more time. Below mentioned functions can take leverage of underlying varchar length and calculate return length. > *LOWER, UPPER, INITCAP, REVERSE, FIRST_VALUE, LAST_VALUE* > Return length is underlying column length, i.e. if column is known, the same length will be returned. > Example: > lower(cast(col as varchar(30))) will return 30. > lower(col) will return max varchar length, since we don't know actual column length. > *LAG, LEAD* > Return length is underlying column length but column type will be nullable. > *LPAD, RPAD* > Pads the string to the length specified. Return length is this specified length. > *CONCAT, CONCAT OPERATOR (||)* > Return length is sum of underlying columns length. If length is greater then varchar max length, varchar max length is returned. > *SUBSTR, SUBSTRING, LEFT, RIGHT* > Calculates return length according to each function substring rules, for example, taking into account how many char should be substracted. > *IF EXPRESSIONS (CASE STATEMENT, COALESCE), UNION OPERATOR* > When combining string columns with different length, return length is max from source columns. -- This message was sent by Atlassian JIRA (v6.3.15#6346)