phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chen Feng (Jira)" <j...@apache.org>
Subject [jira] [Updated] (PHOENIX-5600) "case when" of casting INTEGER to UNSIGNED_LONG throws exception
Date Wed, 04 Dec 2019 01:56:00 GMT

     [ https://issues.apache.org/jira/browse/PHOENIX-5600?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Chen Feng updated PHOENIX-5600:
-------------------------------
    Summary: "case when" of casting INTEGER to UNSIGNED_LONG throws exception  (was: case
when for INTEGER to UNSIGNED_LONG throws exception)

> "case when" of casting INTEGER to UNSIGNED_LONG throws exception
> ----------------------------------------------------------------
>
>                 Key: PHOENIX-5600
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5600
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Chen Feng
>            Priority: Minor
>
> Executing "case when" of casting INTEGER to UNSIGNED_LONG throws exception.
> An example is shown as follows:
> CREATE TABLE IF NOT EXISTS TBL_TEST_CASE_WHEN (A UNSIGNED_LONG NOT NULL, Y FLOAT, Z UNSIGNED_LONG
CONSTRAINT pk PRIMARY KEY (A));
>  UPSERT INTO TBL_TEST_CASE_WHEN VALUES (1, 1, 1);
>  UPSERT INTO TBL_TEST_CASE_WHEN VALUES (2, 2, 2);
> #this works correctly
> SELECT CASE WHEN A = 1 THEN A+9 ELSE A END, CASE WHEN Y > 1 THEN 5.5 ELSE Y END FROM
TBL_TEST_CASE_WHEN;
> #this throws exception
> SELECT CASE WHEN A = 1 THEN 10 ELSE A END, CASE WHEN Y > 1 THEN 5.5 ELSE Y END FROM
TBL_TEST_CASE_WHEN;
>  
> By checking code of PUnsignedLong.java and PInteger.java, I see such comment in PLong.isCoercibleTo(isCoercibleTo),
it says
> // In general, don't allow conversion of LONG to INTEGER. There are times when
>  // we check isComparableTo for a more relaxed check and then throw a runtime
>  // exception if we overflow
> However, in this example, enabling casting a const INTEGER to UNSIGNED_LONG is more comprehensible.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message