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

ASF GitHub Bot commented on DRILL-6345:
---------------------------------------

Github user vvysotskyi commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1230#discussion_r184138785
  
    --- Diff: 
exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewMathFunctions.java
 ---
    @@ -132,4 +148,200 @@ public void testIsNumeric() throws Throwable{
        final Object [] expected = new Object[] {1, 1, 1, 0};
        runTest(expected, "functions/testIsNumericFunction.json");
      }
    +
    +  @Test
    +  public void testLog10WithDouble() throws Throwable {
    +    String json = "{" +
    +          "\"positive_infinity\" : Infinity," +
    +          "\"negative_infinity\" : -Infinity," +
    +          "\"nan\" : NaN," +
    +          "\"num1\": 0.0," +
    +          "\"num2\": 0.1," +
    +          "\"num3\": 1.0," +
    +          "\"num4\": 1.5," +
    +          "\"num5\": -1.5," +
    +          "\"num6\": 10.0" +
    +          "}";
    +    String query = "select " +
    +            "log10(positive_infinity) as pos_inf, " +
    +            "log10(negative_infinity) as neg_inf, " +
    +            "log10(nan) as nan, " +
    +            "log10(num1) as num1, " +
    +            "log10(num2) as num2, " +
    +            "log10(num3) as num3, " +
    +            "log10(num4) as num4, " +
    +            "log10(num5) as num5, " +
    +            "log10(num6) as num6 " +
    +            "" +
    +            "from dfs.`data.json`";
    +    File file = new File(dirTestWatcher.getRootDir(), "data.json");
    +    try {
    +      FileUtils.writeStringToFile(file, json);
    +      test("alter session set `%s` = true", 
ExecConstants.JSON_READ_NUMBERS_AS_DOUBLE);
    +      test("alter session set `%s` = true", 
ExecConstants.JSON_READER_NAN_INF_NUMBERS);
    +      testBuilder()
    +              .sqlQuery(query)
    +              .ordered()
    +              .baselineColumns("pos_inf", "neg_inf", "nan", "num1", 
"num2", "num3", "num4", "num5", "num6")
    +              .baselineValues(Double.POSITIVE_INFINITY, Double.NaN, 
Double.NaN, Double.NEGATIVE_INFINITY,
    +                      -1.0d, 0d, 0.17609125905568124d, Double.NaN, 1.0d)
    +              .build()
    +              .run();
    +    } finally {
    +      test("alter session set `%s` = false", 
ExecConstants.JSON_READ_NUMBERS_AS_DOUBLE);
    +      test("alter session set `%s` = false", 
ExecConstants.JSON_READER_NAN_INF_NUMBERS);
    +      FileUtils.deleteQuietly(file);
    +    }
    +  }
    +
    +  @Test
    +  public void testLog10WithFloat() throws Throwable {
    +    String json = "{" +
    +            "\"positive_infinity\" : Infinity," +
    +            "\"negative_infinity\" : -Infinity," +
    +            "\"nan\" : NaN," +
    +            "\"num1\": 0.0," +
    +            "\"num2\": 0.1," +
    +            "\"num3\": 1.0," +
    +            "\"num4\": 1.5," +
    +            "\"num5\": -1.5," +
    +            "\"num6\": 10.0" +
    +            "}";
    +    String query = "select " +
    +            "log10(cast(positive_infinity as float)) as pos_inf, " +
    +            "log10(cast(negative_infinity as float)) as neg_inf, " +
    +            "log10(cast(nan as float)) as nan, " +
    +            "log10(cast(num1 as float)) as num1, " +
    +            "log10(cast(num2 as float)) as num2, " +
    +            "log10(cast(num3 as float)) as num3, " +
    +            "log10(cast(num4 as float)) as num4, " +
    +            "log10(cast(num5 as float)) as num5, " +
    +            "log10(cast(num6 as float)) as num6 " +
    +            "" +
    +            "from dfs.`data.json`";
    +    File file = new File(dirTestWatcher.getRootDir(), "data.json");
    +    try {
    +      FileUtils.writeStringToFile(file, json);
    +      test("alter session set `%s` = true", 
ExecConstants.JSON_READER_NAN_INF_NUMBERS);
    +      testBuilder()
    +              .sqlQuery(query)
    +              .ordered()
    +              .baselineColumns("pos_inf", "neg_inf", "nan", "num1", 
"num2", "num3", "num4", "num5", "num6")
    +              .baselineValues(Double.POSITIVE_INFINITY, Double.NaN, 
Double.NaN, Double.NEGATIVE_INFINITY,
    +                      -0.999999993528508d, 0d, 0.17609125905568124d, 
Double.NaN, 1.0d)
    +              .build()
    +              .run();
    +    } finally {
    +      test("alter session set `%s` = false", 
ExecConstants.JSON_READER_NAN_INF_NUMBERS);
    +      FileUtils.deleteQuietly(file);
    +    }
    +  }
    +
    +  @Test
    +  public void testLog10WithInt() throws Throwable {
    +    String json = "{" +
    +            "\"num1\": 0.0," +
    +            "\"num3\": 1.0," +
    +            "\"num5\": -1.0," +
    +            "\"num6\": 10.0" +
    +            "}";
    +    String query = "select " +
    +            "log10(cast(num1 as int)) as num1, " +
    +            "log10(cast(num3 as int)) as num3, " +
    +            "log10(cast(num5 as int)) as num5, " +
    +            "log10(cast(num6 as int)) as num6 " +
    +            "" +
    +            "from dfs.`data.json`";
    +    File file = new File(dirTestWatcher.getRootDir(), "data.json");
    +    try {
    +      FileUtils.writeStringToFile(file, json);
    +      test("alter session set `%s` = true", 
ExecConstants.JSON_READER_NAN_INF_NUMBERS);
    +      testBuilder()
    +              .sqlQuery(query)
    +              .ordered()
    +              .baselineColumns("num1",  "num3", "num5", "num6")
    +              .baselineValues(Double.NEGATIVE_INFINITY, 0d, Double.NaN, 
1.0d)
    +              .build()
    +              .run();
    +    } finally {
    +      test("alter session set `%s` = false", 
ExecConstants.JSON_READER_NAN_INF_NUMBERS);
    +      FileUtils.deleteQuietly(file);
    +    }
    +  }
    +
    +  @Test
    +  public void testLog10WithBigInt() throws Throwable {
    +    String json = "{" +
    +            "\"num1\": 0," +
    +            "\"num3\": 1," +
    +            "\"num5\": -1," +
    +            "\"num6\": 10" +
    +            "}";
    +    String query = "select " +
    +            "log10(num1) as num1, " +
    +            "log10( num3) as num3, " +
    --- End diff --
    
    please remove space before `num3`


> Add LOG10 function implementation
> ---------------------------------
>
>                 Key: DRILL-6345
>                 URL: https://issues.apache.org/jira/browse/DRILL-6345
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Functions - Drill
>            Reporter: Volodymyr Tkach
>            Assignee: Volodymyr Tkach
>            Priority: Major
>             Fix For: 1.14.0
>
>
> Add LOG10 function implementation.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to