[ https://issues.apache.org/jira/browse/HIVE-24315?focusedWorklogId=568862&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-568862 ]
ASF GitHub Bot logged work on HIVE-24315: ----------------------------------------- Author: ASF GitHub Bot Created on: 19/Mar/21 09:53 Start Date: 19/Mar/21 09:53 Worklog Time Spent: 10m Work Description: zeroflag commented on a change in pull request #2059: URL: https://github.com/apache/hive/pull/2059#discussion_r597541167 ########## File path: hplsql/src/main/java/org/apache/hive/hplsql/Expression.java ########## @@ -369,21 +380,32 @@ public void operatorSub(HplsqlParser.ExprContext ctx) { 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) { + } 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.BIGINT && v2.type == Type.DECIMAL) { + exec.stackPush(new Var((new BigDecimal((long)v1.value)).subtract((BigDecimal)v2.value))); + } else if (v1.type == Type.BIGINT && v2.type == Type.DOUBLE) { + exec.stackPush(new Var((long)v1.value - (double)v2.value)); + } else if (v1.type == Type.DECIMAL && v2.type == Type.DECIMAL) { + exec.stackPush(new Var(((BigDecimal) v1.value).subtract((BigDecimal) v2.value))); + } else if (v1.type == Type.DECIMAL && v2.type == Type.BIGINT) { + exec.stackPush(new Var(((BigDecimal)v1.value).subtract(new BigDecimal((long)v2.value)))); + } else if (v1.type == Type.DECIMAL && v2.type == Type.DOUBLE) { + exec.stackPush(new Var(((BigDecimal) v1.value).subtract(new BigDecimal((double) v2.value)))); + } else if (v1.type == Type.DOUBLE && v2.type == Type.DOUBLE) { + exec.stackPush(new Var((double) v1.value - (double) v2.value)); + } else if (v1.type == Type.DOUBLE && v2.type == Type.DECIMAL) { + exec.stackPush(new Var((new BigDecimal((double) v1.value)).subtract((BigDecimal) v2.value))); + } else if (v1.type == Type.DOUBLE && v2.type == Type.BIGINT) { + exec.stackPush(new Var(((double) 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) { + } 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(); + } else { + exec.signal(Signal.Type.UNSUPPORTED_OPERATION, "Unsupported data types in subtraction operator"); Review comment: good idea -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 568862) Time Spent: 40m (was: 0.5h) > Improve validation and error handling in HPL/SQL > ------------------------------------------------- > > Key: HIVE-24315 > URL: https://issues.apache.org/jira/browse/HIVE-24315 > Project: Hive > Issue Type: Sub-task > Components: hpl/sql > Reporter: Attila Magyar > Assignee: Attila Magyar > Priority: Major > Labels: pull-request-available > Time Spent: 40m > Remaining Estimate: 0h > > There are some known issues that need to be fixed. For example it seems that > arity of a function is not checked when calling it, and same is true for > parameter types. Calling an undefined function is evaluated to null and > sometimes it seems that incorrect syntax is silently ignored. > In cases like this a helpful error message would be expected, thought we > should also consider how PL/SQL works and maintain compatibility. -- This message was sent by Atlassian Jira (v8.3.4#803005)