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 5893D1072C for ; Wed, 11 Feb 2015 03:04:12 +0000 (UTC) Received: (qmail 44042 invoked by uid 500); 11 Feb 2015 03:04:12 -0000 Delivered-To: apmail-drill-issues-archive@drill.apache.org Received: (qmail 43950 invoked by uid 500); 11 Feb 2015 03:04:11 -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 43902 invoked by uid 99); 11 Feb 2015 03:04:11 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Feb 2015 03:04:11 +0000 Date: Wed, 11 Feb 2015 03:04:11 +0000 (UTC) From: "Jinfeng Ni (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DRILL-2199) Wrong results while using case expression with decimal data type 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-2199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14315487#comment-14315487 ] Jinfeng Ni commented on DRILL-2199: ----------------------------------- +1 > Wrong results while using case expression with decimal data type > ---------------------------------------------------------------- > > Key: DRILL-2199 > URL: https://issues.apache.org/jira/browse/DRILL-2199 > Project: Apache Drill > Issue Type: Bug > Reporter: Mehant Baid > Assignee: Jinfeng Ni > Attachments: DRILL-2199.patch > > > Consider the below SQL statement: > "select > case when true then cast(employee_id as decimal(15, 5)) else cast('0.0' as decimal(5, 2)) end > from cp.`employee.json` where employee_id = 1" > This should return 1.00000 instead Drill returns 100000. In the case statement the first expression (condition expression) is nullable and the else expression is non-nullable. For our codegen to work correctly we make the non-nullable expression also nullable using convertToNullableXHolder() functions. These functions however do not preserve the scale and precision of the input, hence the output we get is the unscaled value of the decimal. > Fix is to make the converToNullableDecimalHolder() functions preserve the scale and precision by returning the correct major type. -- This message was sent by Atlassian JIRA (v6.3.4#6332)