[ 
https://issues.apache.org/jira/browse/TAJO-978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14078794#comment-14078794
 ] 

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_r15564099
  
    --- Diff: 
tajo-core/src/test/java/org/apache/tajo/engine/function/TestMathFunctions.java 
---
    @@ -428,19 +430,27 @@ public void testPi() throws IOException {
     
       @Test
       public void testRoundWithSpecifiedPrecision() throws IOException {
    +    // divide zero
    +    try {
    +      testSimpleEval("select round(10.0/0.0,2) ", new String[]{""});
    +      fail("10.0/0 should throw InvalidOperationException");
    +    } catch (InvalidOperationException e) {
    +      //success
    +    }
    +
         testSimpleEval("select round(42.4382,2) ", new String[]{"42.44"});
         testSimpleEval("select round(-42.4382,2) ", new String[]{"-42.44"});
    -    testSimpleEval("select round(-425,2) ", new String[]{"-425"});
    -    testSimpleEval("select round(425,2) ", new String[]{"425"});
    +    testSimpleEval("select round(-425,2) ", new String[]{"-425.0"});
    +    testSimpleEval("select round(425,2) ", new String[]{"425.0"});
     
    -    testSimpleEval("select round(1234567890,0) ", new 
String[]{"1234567890"});
    -    testSimpleEval("select round(1234567890,1) ", new 
String[]{"1234567890"});
    -    testSimpleEval("select round(1234567890,2) ", new 
String[]{"1234567890"});
    +    testSimpleEval("select round(1234567890,0) ", new 
String[]{"1.23456789E9"});
    +    testSimpleEval("select round(1234567890,1) ", new 
String[]{"1.23456789E9"});
    +    testSimpleEval("select round(1234567890,2) ", new 
String[]{"1.23456789E9"});
     
         testSimpleEval("select round(1.2345678901234567,13) ", new 
String[]{"1.2345678901235"});
    -    testSimpleEval("select round(1234567890.1234567,3) ", new 
String[]{"1234567890.123"});
    -    testSimpleEval("select round(1234567890.1234567,5) ", new 
String[]{"1234567890.12346"});
    -    //testSimpleEval("select round(1234567890.1234567890,7) ", new 
String[]{"1234567890.1234568"});
    +    testSimpleEval("select round(1234567890.1234567,3) ", new 
String[]{"1.234567890123E9"});
    +    testSimpleEval("select round(1234567890.1234567,5) ", new 
String[]{"1.23456789012346E9"});
    +//testSimpleEval("select round(1234567890.1234567890,7) ", new 
String[]{"1234567890.1234568"});
    --- End diff --
    
    I'll remove.


> 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)

Reply via email to