Review Board 1.7.22


DRILL-248 : Implementation of scalar functions (subtract, multiply, division)

Review Request #14378 - Created Sept. 27, 2013 and updated

Yash Sharma
Reviewers
drill-git
drill-git
Implemented Scalar functions: Subtract, Multiply, Division.

Known Issue:

Division Function has known Issue:
Only works with Integer return types. The return type for division of numbers returns an Integer value always.
Clarifications:
10/2 returns 5
11/2 also returns 5, instead of 5.5.
SQLLINE:

0: jdbc:drill:schema=parquet-local> select 10+2 from "sample-data/region.parquet";
+---------+
| EXPR$0  |
+---------+
| 12      |
| 12      |
| 12      |
| 12      |
| 12      |
+---------+
5 rows selected (2.77 seconds)
0: jdbc:drill:schema=parquet-local> select 10-2 from "sample-data/region.parquet";
+---------+
| EXPR$0  |
+---------+
| 8       |
| 8       |
| 8       |
| 8       |
| 8       |
+---------+
5 rows selected (0.583 seconds)
0: jdbc:drill:schema=parquet-local> select 10*2 from "sample-data/region.parquet";
+---------+
| EXPR$0  |
+---------+
| 20      |
| 20      |
| 20      |
| 20      |
| 20      |
+---------+
5 rows selected (0.479 seconds)
0: jdbc:drill:schema=parquet-local> select 10/2 from "sample-data/region.parquet";
+---------+
| EXPR$0  |
+---------+
| 5       |
| 5       |
| 5       |
| 5       |
| 5       |
+---------+
5 rows selected (0.398 seconds)



-------
Test Case:
mvn test -Dtest=RunSimplePlan#scalarFunctionsPlan


{
  "subtract" : 8,
  "divide" : 5,
  "multiply" : 20,
  "add" : 12
} 
 {
  "subtract" : 8,
  "divide" : 5,
  "multiply" : 20,
  "add" : 12
} 
 {
  "subtract" : 8,
  "divide" : 5,
  "multiply" : 20,
  "add" : 12
} 
 {
  "subtract" : 8,
  "divide" : 5,
  "multiply" : 20,
  "add" : 12
} 
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.124 sec - in org.apache.drill.exec.ref.RunSimplePlan

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.779s
[INFO] Finished at: Fri Sep 27 23:43:28 IST 2013
[INFO] Final Memory: 28M/341M
[INFO] ------------------------------------------------------------------------
Review request changed
Updated (Sept. 27, 2013, 7:02 p.m.)
  • Implemented Scalar functions: Subtract, Multiply, Division.
    
    Known Issue:
    
    Division Function has known Issue:
    Only works with Integer data types. The return type for division of numbers returns an Integer value always.
    Clarifications:
    10/2 returns 5
    11/2 also returns 5, instead of 5.5.

    Implemented Scalar functions: Subtract, Multiply, Division.
    
    Known Issue:
    
    Division Function has known Issue:
    Only works with Integer return types. The return type for division of numbers returns an Integer value always.
    Clarifications:
    10/2 returns 5
    11/2 also returns 5, instead of 5.5.