Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill >> mail # dev >> Review Request 14378: DRILL-248 : Implementation of scalar functions (subtract, multiply, division)


Copy link to this message
-
Re: Review Request 14378: DRILL-248 : Implementation of scalar functions (subtract, multiply, division)

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/14378/
-----------------------------------------------------------

(Updated Sept. 27, 2013, 7:02 p.m.)
Review request for drill.
Repository: drill-git
Description (updated)
-------

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.
Diffs
-----

  exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MathFunctions.java 288760b
  exec/ref/src/main/java/org/apache/drill/exec/ref/eval/fn/MathEvaluators.java 347a4f3
  exec/ref/src/main/java/org/apache/drill/exec/ref/values/NumericValue.java f32a80e
  exec/ref/src/test/java/org/apache/drill/exec/ref/RunSimplePlan.java f4992e0
  exec/ref/src/test/resources/scalar_func.json PRE-CREATION

Diff: https://reviews.apache.org/r/14378/diff/
Testing
-------

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] ------------------------------------------------------------------------
Thanks,

Yash Sharma