From dev-return-13666-archive-asf-public=cust-asf.ponee.io@calcite.apache.org Mon Oct 14 14:24:02 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 5CC4818067C for ; Mon, 14 Oct 2019 16:24:02 +0200 (CEST) Received: (qmail 64647 invoked by uid 500); 14 Oct 2019 14:24:01 -0000 Mailing-List: contact dev-help@calcite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@calcite.apache.org Delivered-To: mailing list dev@calcite.apache.org Received: (qmail 64625 invoked by uid 99); 14 Oct 2019 14:24:01 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Oct 2019 14:24:01 +0000 Received: from jira-he-de.apache.org (static.172.67.40.188.clients.your-server.de [188.40.67.172]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 88A86E2E39 for ; Mon, 14 Oct 2019 14:24:00 +0000 (UTC) Received: from jira-he-de.apache.org (localhost.localdomain [127.0.0.1]) by jira-he-de.apache.org (ASF Mail Server at jira-he-de.apache.org) with ESMTP id 07381780579 for ; Mon, 14 Oct 2019 14:24:00 +0000 (UTC) Date: Mon, 14 Oct 2019 14:24:00 +0000 (UTC) From: "Feng Zhu (Jira)" To: dev@calcite.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (CALCITE-3411) Incorrect code generated for BigDecimal ConstantExpression MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Feng Zhu created CALCITE-3411: --------------------------------- Summary: Incorrect code generated for BigDecimal ConstantExpression Key: CALCITE-3411 URL: https://issues.apache.org/jira/browse/CALCITE-3411 Project: Calcite Issue Type: Bug Affects Versions: 1.21.0 Reporter: Feng Zhu Assignee: Feng Zhu In current implementation {code:java} Expressions.constant("104", BigDecimal.class) -> new java.math.BigDecimal(104L) Expressions.constant("1000", BigDecimal.class) -> new java.math.BigDecimal(1L, -3){code} However, in *java.math.BigDecimal*, there is no constructor: {code:java} java.math.BigDecimal(long exact, int scale) {code} Instead we should call method {code:java} java.math.BigDecimal.valueOf(long exact, int scale){code} h4. *Why this issue did not exposed before?* *BlockBuilder* conducts optimizations that can bury this issue. For example, when we disable the optimization. _MaterializationTest#testAggregateMaterializationAggregateFuncs11_ will produce the code below. However, it can't pass the compilation. {code:java} final long v = org.apache.calcite.runtime.SqlFunctions.floor(853763696000L, ((Long) new java.math.BigDecimal(1L, -3)).longValue());{code} -- This message was sent by Atlassian Jira (v8.3.4#803005)