[
https://issues.apache.org/jira/browse/HIVE-17031?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dmitry Tolpeko updated HIVE-17031:
----------------------------------
Attachment: HIVE-17031.1.patch
> HPL/SQL Addition/Subtraction only supported on integers, datetimes and
> intervals
> --------------------------------------------------------------------------------
>
> Key: HIVE-17031
> URL: https://issues.apache.org/jira/browse/HIVE-17031
> Project: Hive
> Issue Type: Bug
> Components: hpl/sql
> Reporter: Carter Shanklin
> Assignee: Dmitry Tolpeko
> Priority: Critical
> Attachments: HIVE-17031.1.patch
>
>
> This bug is part of a series of issues and surprising behavior I encountered
> writing a reporting script that would aggregate values and give rows
> different classifications based on an the aggregate. Addressing some or all
> of these issues would make HPL/SQL more accessible to newcomers.
> In Expression.java:
> {code}
> public void operatorSub(HplsqlParser.ExprContext ctx) {
> Var v1 = evalPop(ctx.expr(0));
> Var v2 = evalPop(ctx.expr(1));
> if (v1.value == null || v2.value == null) {
> evalNull();
> }
> else if (v1.type == Type.BIGINT && v2.type == Type.BIGINT) {
> exec.stackPush(new Var((Long)v1.value - (Long)v2.value));
> }
> else if (v1.type == Type.DATE && v2.type == Type.BIGINT) {
> exec.stackPush(changeDateByInt((Date)v1.value, (Long)v2.value, false
> /*subtract*/));
> }
> else if (v1.type == Type.DATE && v2.type == Type.INTERVAL) {
> exec.stackPush(new Var(((Interval)v2.value).dateChange((Date)v1.value,
> false /*subtract*/)));
> }
> else if (v1.type == Type.TIMESTAMP && v2.type == Type.INTERVAL) {
> exec.stackPush(new
> Var(((Interval)v2.value).timestampChange((Timestamp)v1.value, false
> /*subtract*/), v1.scale));
> }
> else {
> evalNull();
> }
> }
> {code}
> So decimals and floating points are not considered. To be fair the docs don't
> mention this as supported, but it is surprising.
> Need: Test case for comparisons and equality, including nulls
> Version = 3.0.0-SNAPSHOT r71f52d8ad512904b3f2c4f04fe39a33f2834f1f2
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)