[
https://issues.apache.org/jira/browse/TAJO-978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14078793#comment-14078793
]
ASF GitHub Bot commented on TAJO-978:
-------------------------------------
Github user babokim commented on a diff in the pull request:
https://github.com/apache/tajo/pull/96#discussion_r15564097
--- Diff:
tajo-core/src/main/java/org/apache/tajo/engine/function/math/RoundFloat8.java
---
@@ -70,23 +63,21 @@ public Datum eval(Tuple params) {
return NullDatum.get();
}
- if (numberFormat == null || !formatConstant) {
- numberFormat = NumberFormat.getInstance();
- numberFormat.setGroupingUsed(false);
- numberFormat.setMaximumFractionDigits(roundDatum.asInt4());
- }
-
double value = valueDatum.asFloat8();
- int roundPnt = roundDatum.asInt4();
- double roundNum;
+ int rountPoint = roundDatum.asInt4();
- if (value > 0) {
- roundNum = (long)(value * Math.pow(10, roundPnt) + 0.5d) /
Math.pow(10, roundPnt);
+ if (Double.isNaN(value)) {
+ throw new InvalidOperationException("value is not a number");
}
- else {
- roundNum = (long)(value * Math.pow(10, roundPnt) - 0.5d) /
Math.pow(10, roundPnt);
+
+ if (Double.isInfinite(value)) {
+ throw new InvalidOperationException("/ by zero");
--- End diff --
Ok. I'll change "value is infinite."
> RoundFloat8 should return Float8Datum type.
> -------------------------------------------
>
> Key: TAJO-978
> URL: https://issues.apache.org/jira/browse/TAJO-978
> Project: Tajo
> Issue Type: Bug
> Reporter: Hyoungjun Kim
> Assignee: Hyoungjun Kim
> Priority: Minor
>
> Currently RoundFloat8 function returns TextDatum. So the following query
> occurs InvalidOperationException.
> {code:sql}
> select * from (
> select n_nationkey as key,
> case when n_nationkey < 6
> then round((n_nationkey * 100 / 2.123)::float4 /
> (n_regionkey + 1)::float4, 2)
> else 100.0
> end as val
> from nation) a
> order by a.key
> {code}
> {noformat}
> 2014-07-25 16:40:08,418 ERROR: org.apache.tajo.worker.Task (run(432)) -
> Cannot compare to FLOAT8 type datum
> org.apache.tajo.exception.InvalidOperationException: Cannot compare to FLOAT8
> type datum
> at org.apache.tajo.datum.TextDatum.compareTo(TextDatum.java:113)
> at
> org.apache.tajo.storage.TableStatistics.analyzeField(TableStatistics.java:91)
> at
> org.apache.tajo.storage.RawFile$RawFileAppender.addTuple(RawFile.java:600)
> at
> org.apache.tajo.engine.planner.physical.RangeShuffleFileWriteExec.next(RangeShuffleFileWriteExec.java:101)
> at org.apache.tajo.worker.Task.run(Task.java:425)
> at org.apache.tajo.worker.TaskRunner$1.run(TaskRunner.java:406)
> at java.lang.Thread.run(Thread.java:744)
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.2#6252)