Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/863#discussion_r124954136
  
    --- Diff: 
exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java
 ---
    @@ -78,4 +81,71 @@ public void testToDateForTimeStamp() throws Exception {
             .build()
             .run();
       }
    +
    +  @Test // DRILL-4970
    +  public void testCastNegativeFloatToInt() throws Exception {
    +    try {
    +      test("create table dfs_test.tmp.table_with_float as\n" +
    +              "(select cast(-255.0 as double) as double_col,\n" +
    +                      "cast(-255.0 as float) as float_col\n" +
    +              "from (values(1)))");
    +
    +      final List<String> columnNames = Lists.newArrayList();
    +      columnNames.add("float_col");
    +      columnNames.add("double_col");
    +
    +      final List<String> castTypes = Lists.newArrayList();
    +      castTypes.add("int");
    +      castTypes.add("bigInt");
    +
    +      final String query = "select count(*) as c from 
dfs_test.tmp.table_with_float\n" +
    +                            "where (cast(%1$s as %2$s) >= -255 and (%1$s 
<= -5)) or (%1$s <= -256)";
    +
    +      for (String columnName : columnNames) {
    +        for (String castType : castTypes) {
    +          testBuilder()
    +            .sqlQuery(query, columnName, castType)
    +            .unOrdered()
    +            .baselineColumns("c")
    +            .baselineValues(1L)
    +            .build()
    +            .run();
    +        }
    +      }
    +    } finally {
    +      test("drop table if exists dfs_test.tmp.table_with_float");
    +    }
    +  }
    +
    +  @Test // DRILL-4970
    +  public void testCastNegativeDecimalToVarChar() throws Exception {
    --- End diff --
    
    There are two tests here. Should we not test all cast functions to 
determine if others have similar issues: (short, int, long, float, double, 
decimal 9, decimal 18, etc.) --> (short, int, long, float, double, decimal 9, 
decimal 18, etc.)
    
    This is a reason to do basic JUnit tests without the server: much easier to 
try all the boundary values for every type to every other type. That testing is 
tedious, yes. But, much less tedious using the functions directly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to