You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by pa...@apache.org on 2015/02/23 20:53:12 UTC
[3/4] drill git commit: DRILL-1062: Implemented null ordering (NULLS
FIRST/NULLS LAST).
http://git-wip-us.apache.org/repos/asf/drill/blob/5efc7e68/exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java b/exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java
index 0c4af01..b9029cd 100644
--- a/exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java
@@ -20,212 +20,76 @@ import org.apache.drill.exec.expr.annotations.Workspace;
<@pp.dropOutputFile />
-<#macro compareBlock holderType left right absCompare output>
-
- outside:{
- ${output} = org.apache.drill.exec.util.DecimalUtility.compareSparseBytes(left.buffer, left.start, left.getSign(left.start, left.buffer),
- left.scale, left.precision, right.buffer,
- right.start, right.getSign(right.start, right.buffer), right.precision,
- right.scale, left.WIDTH, left.nDecimalDigits, ${absCompare});
-
- }
-</#macro>
-
-<#macro subtractBlock holderType in1 in2 result>
-
- int resultScaleRoundedUp = org.apache.drill.exec.util.DecimalUtility.roundUp(result.scale);
- int resultIndex = result.nDecimalDigits- 1;
-
- int leftScaleRoundedUp = org.apache.drill.exec.util.DecimalUtility.roundUp(${in1}.scale);
- int leftIntRoundedUp = org.apache.drill.exec.util.DecimalUtility.roundUp(${in1}.precision - ${in1}.scale);
- int rightScaleRoundedUp = org.apache.drill.exec.util.DecimalUtility.roundUp(${in2}.scale);
-
- int leftIndex = ${in1}.nDecimalDigits - 1;
- int rightIndex = ${in2}.nDecimalDigits - 1;
-
- /* If the left scale is bigger, simply copy over the digits into result */
- while (leftScaleRoundedUp > rightScaleRoundedUp) {
- result.setInteger(resultIndex, ${in1}.getInteger(leftIndex, ${in1}.start, ${in1}.buffer), result.start, result.buffer);
- leftIndex--;
- resultIndex--;
- leftScaleRoundedUp--;
- }
-
- /* If the right scale is bigger, subtract with zero at each array location */
- int carry = 0;
- while(rightScaleRoundedUp > leftScaleRoundedUp) {
-
- int difference = 0 - ${in2}.getInteger(rightIndex, ${in2}.start, ${in2}.buffer) - carry;
- rightIndex--;
-
- if (difference < 0) {
- carry = 1;
- result.setInteger(resultIndex, (difference + org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE), result.start, result.buffer);
- } else {
- result.setInteger(resultIndex, difference, result.start, result.buffer);
- carry = 0;
- }
- resultIndex--;
- rightScaleRoundedUp--;
-
- }
-
- /* Now both the scales are equal perform subtraction use one of the scales
- * for terminal condition in the while loop
- */
- while (leftScaleRoundedUp > 0) {
-
- int difference = ${in1}.getInteger(leftIndex, ${in1}.start, ${in1}.buffer) - ${in2}.getInteger(rightIndex, ${in2}.start, ${in2}.buffer) - carry;
- leftIndex--;
- rightIndex--;
-
- if (difference < 0) {
- carry = 1;
- result.setInteger(resultIndex, (difference + org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE), result.start, result.buffer);
- } else {
- result.setInteger(resultIndex, difference, result.start, result.buffer);
- carry = 0;
- }
- resultIndex--;
- leftScaleRoundedUp--;
- }
-
- /* Since we are gurranteed to have the left input >= right input, iterate
- * over the remaining left input's integers
- */
- while(leftIntRoundedUp > 0) {
-
- int difference = ${in1}.getInteger(leftIndex, ${in1}.start, ${in1}.buffer);
- leftIndex--;
-
- if (rightIndex >= 0) {
- difference -= ${in2}.getInteger(rightIndex, ${in2}.start, ${in2}.buffer);
- rightIndex--;
- }
-
- difference -= carry;
-
- if (difference < 0) {
- carry = 1;
- result.setInteger(resultIndex, (difference + org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE), result.start, result.buffer);
- } else {
- carry = 0;
- result.setInteger(resultIndex, difference, result.start, result.buffer);
- }
- resultIndex--;
- leftIntRoundedUp--;
- }
+<#-- TODO: Refactor comparison code from here into ComparisonFunctions (to
+ eliminate duplicate template code and so that ComparisonFunctions actually
+ as all comparison functions. -->
+
+<#macro compareNullsSubblock leftType rightType output breakTarget nullCompare nullComparesHigh>
+ <#if nullCompare>
+ <#if nullComparesHigh>
+ <#assign leftNullResult = 1> <#-- if only L is null and nulls are high, then "L > R" (1) -->
+ <#assign rightNullResult = -1>
+ <#else>
+ <#assign leftNullResult = -1> <#-- if only L is null and nulls are low, then "L < R" (-1) -->
+ <#assign rightNullResult = 1>
+ </#if>
+
+ <#if leftType?starts_with("Nullable")>
+ <#if rightType?starts_with("Nullable")>
+ <#-- Both are nullable. -->
+ if ( left.isSet == 0 ) {
+ if ( right.isSet == 0 ) {
+ <#-- Both are null--result is "L = R". -->
+ ${output} = 0;
+ break ${breakTarget};
+ } else {
+ <#-- Only left is null--result is "L < R" or "L > R" per null ordering. -->
+ ${output} = ${leftNullResult};
+ break ${breakTarget};
+ }
+ } else if ( right.isSet == 0 ) {
+ <#-- Only right is null--result is "L > R" or "L < R" per null ordering. -->
+ ${output} = ${rightNullResult};
+ break ${breakTarget};
+ }
+ <#else>
+ <#-- Left is nullable but right is not. -->
+ if ( left.isSet == 0 ) {
+ <#-- Only left is null--result is "L < R" or "L > R" per null ordering. -->
+ ${output} = ${leftNullResult};
+ break ${breakTarget};
+ }
+ </#if>
+ <#elseif rightType?starts_with("Nullable")>
+ <#-- Left is not nullable but right is. -->
+ if ( right.isSet == 0 ) {
+ <#-- Only right is null--result is "L > R" or "L < R" per null ordering. -->
+ ${output} = ${rightNullResult};
+ break ${breakTarget};
+ }
+ </#if>
+ </#if>
</#macro>
-<#macro addBlock holderType in1 in2 result>
-
- int resultScaleRoundedUp = org.apache.drill.exec.util.DecimalUtility.roundUp(result.scale);
-
- int leftScaleRoundedUp = org.apache.drill.exec.util.DecimalUtility.roundUp(${in1}.scale);
- int rightScaleRoundedUp = org.apache.drill.exec.util.DecimalUtility.roundUp(${in2}.scale);
-
- /* starting index for each decimal */
- int leftIndex = ${in1}.nDecimalDigits - 1;
- int rightIndex = ${in2}.nDecimalDigits - 1;
- int resultIndex = result.nDecimalDigits - 1;
-
- /* If one of the scale is larger then simply copy it over
- * to the result digits
- */
- while (leftScaleRoundedUp > rightScaleRoundedUp) {
-
- result.setInteger(resultIndex, ${in1}.getInteger(leftIndex, ${in1}.start, ${in1}.buffer), result.start, result.buffer);
- leftIndex--;
- resultIndex--;
- leftScaleRoundedUp--;
- resultScaleRoundedUp--;
- }
-
- while (rightScaleRoundedUp > leftScaleRoundedUp) {
- result.setInteger((resultIndex), ${in2}.getInteger(rightIndex, ${in2}.start, ${in2}.buffer), result.start, result.buffer);
- rightIndex--;
- resultIndex--;
- rightScaleRoundedUp--;
- resultScaleRoundedUp--;
- }
-
- int sum = 0;
- /* now the two scales are at the same level, we can add them */
- while (resultScaleRoundedUp > 0) {
-
- sum += ${in1}.getInteger(leftIndex, ${in1}.start, ${in1}.buffer) + ${in2}.getInteger(rightIndex, ${in2}.start, ${in2}.buffer);
- leftIndex--;
- rightIndex--;
-
- if (sum >= org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE) {
- result.setInteger(resultIndex, (sum - org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE), result.start, result.buffer);
- sum = 1;
- } else {
- result.setInteger(resultIndex, sum, result.start, result.buffer);
- sum = 0;
- }
- resultIndex--;
- resultScaleRoundedUp--;
- }
-
- /* add the integer part */
- while (leftIndex >= 0 && rightIndex >= 0) {
-
- sum += ${in1}.getInteger(leftIndex, ${in1}.start, ${in1}.buffer) + ${in2}.getInteger(rightIndex, ${in2}.start, ${in2}.buffer);
- leftIndex--;
- rightIndex--;
-
- if (sum >= org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE) {
- result.setInteger(resultIndex, (sum - org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE), result.start, result.buffer);
- sum = 1;
- } else {
- result.setInteger(resultIndex, sum, result.start, result.buffer);
- sum = 0;
- }
- resultIndex--;
- }
-
- while (resultIndex >= 0 && leftIndex >= 0) {
- sum += ${in1}.getInteger(leftIndex, ${in1}.start, ${in1}.buffer);
- leftIndex--;
-
- if (sum >= org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE) {
- result.setInteger(resultIndex, (sum - org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE), result.start, result.buffer);
- sum = 1;
- } else {
- result.setInteger(resultIndex, sum, result.start, result.buffer);
- sum = 0;
- }
- }
-
- while (resultIndex >= 0 && rightIndex >= 0) {
- sum += ${in2}.getInteger(rightIndex, ${in2}.start, ${in2}.buffer);
- rightIndex--;
-
- if (sum >= org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE) {
- result.setInteger(resultIndex, (sum - org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE), result.start, result.buffer);
- sum = 1;
- } else {
- result.setInteger(resultIndex, sum, result.start, result.buffer);
- sum = 0;
- }
- }
+<#macro compareBlock leftType rightType absCompare output nullCompare nullComparesHigh>
+ outside:
+ {
+ <@compareNullsSubblock leftType=leftType rightType=rightType output=output breakTarget="outside" nullCompare=nullCompare nullComparesHigh=nullComparesHigh />
- /* store the last carry */
- if (sum > 0)
- result.setInteger(resultIndex, sum, result.start, result.buffer);
+ ${output} = org.apache.drill.exec.util.DecimalUtility.compareSparseBytes(left.buffer, left.start, left.getSign(left.start, left.buffer),
+ left.scale, left.precision, right.buffer,
+ right.start, right.getSign(right.start, right.buffer), right.precision,
+ right.scale, left.WIDTH, left.nDecimalDigits, ${absCompare});
+ } // outside
</#macro>
-
-<#macro adjustScale holderType javaType left right>
+<#macro adjustScale javaType leftType rightType>
// Adjust the scale of the two inputs to be the same
- int adjustment = 0;
-
if (left.scale < right.scale) {
left.value = (${javaType}) (org.apache.drill.exec.util.DecimalUtility.adjustScaleMultiply(left.value, (int) (right.scale - left.scale)));
left.scale = right.scale;
@@ -235,9 +99,11 @@ import org.apache.drill.exec.expr.annotations.Workspace;
}
</#macro>
-<#list decimal.decimalTypes as type>
+<#-- For each DECIMAL... type (in DecimalTypes.tdd) ... -->
+<#list comparisonTypesDecimal.decimalTypes as type>
<#if type.name.endsWith("Sparse")>
+
<@pp.changeOutputFile name="/org/apache/drill/exec/expr/fn/impl/${type.name}Functions.java" />
<#include "/@includes/license.ftl" />
@@ -252,6 +118,7 @@ import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
import org.apache.drill.exec.expr.annotations.Output;
import org.apache.drill.exec.expr.annotations.Param;
import org.apache.drill.exec.expr.annotations.Workspace;
+import org.apache.drill.exec.expr.fn.FunctionGenerationHelper;
import org.apache.drill.exec.expr.holders.*;
import org.apache.drill.exec.record.RecordBatch;
@@ -295,7 +162,7 @@ public class ${type.name}Functions {
java.math.BigDecimal rightInput = org.apache.drill.exec.util.DecimalUtility.getBigDecimalFromSparse(right.buffer, right.start, right.nDecimalDigits, right.scale);
java.math.BigDecimal addResult = leftInput.subtract(rightInput);
- // set the scale
+ // Set the scale
addResult.setScale(result.scale, java.math.BigDecimal.ROUND_HALF_UP);
org.apache.drill.exec.util.DecimalUtility.getSparseFromBigDecimal(addResult, result.buffer, result.start, result.scale, result.precision, result.nDecimalDigits);
}
@@ -333,7 +200,7 @@ public class ${type.name}Functions {
java.math.BigDecimal rightInput = org.apache.drill.exec.util.DecimalUtility.getBigDecimalFromSparse(right.buffer, right.start, right.nDecimalDigits, right.scale);
java.math.BigDecimal addResult = leftInput.add(rightInput);
- // set the scale
+ // Set the scale
addResult.setScale(result.scale, java.math.BigDecimal.ROUND_HALF_UP);
org.apache.drill.exec.util.DecimalUtility.getSparseFromBigDecimal(addResult, result.buffer, result.start, result.scale, result.precision, result.nDecimalDigits);
}
@@ -387,7 +254,7 @@ public class ${type.name}Functions {
int leftIntegerSize = leftStopIndex - leftIndex;
- /* Remove the leaing zeroes from the integer part of the input */
+ /* Remove the leading zeroes from the integer part of the input */
int rightIndex = 0;
int rightStopIndex = right.nDecimalDigits - org.apache.drill.exec.util.DecimalUtility.roundUp(right.scale);
@@ -429,7 +296,7 @@ public class ${type.name}Functions {
currentIndex--;
}
- /* propogate the carry */
+ /* Propagate the carry */
if (carry > 0)
tempResult[currentIndex] += carry;
@@ -442,17 +309,17 @@ public class ${type.name}Functions {
resultScaleSize = org.apache.drill.exec.util.DecimalUtility.roundUp(result.scale);
if (result.scale < (left.scale + right.scale)) {
- /* The scale of the output data type is lesser than the scale
+ /* The scale of the output data type is less than the scale
* we obtained as a result of multiplication, we need to round
* a chunk of the fractional part
*/
int lastScaleIndex = currentIndex + resultIntegerSize + resultScaleSize - 1;
- // compute the power of 10 necessary to find if we need to round up
+ // Compute the power of 10 necessary to find if we need to round up
int roundFactor = (int) (org.apache.drill.exec.util.DecimalUtility.getPowerOfTen(
org.apache.drill.exec.util.DecimalUtility.MAX_DIGITS - ((result.scale + 1) % org.apache.drill.exec.util.DecimalUtility.MAX_DIGITS)));
- // index of rounding digit
+ // Index of rounding digit
int roundIndex = currentIndex + resultIntegerSize + org.apache.drill.exec.util.DecimalUtility.roundUp(result.scale + 1) - 1;
// Check the first chopped digit to see if we need to round up
@@ -471,7 +338,7 @@ public class ${type.name}Functions {
carry *= scaleFactor;
}
- // propogate the carry
+ // Propagate the carry
while (carry > 0 && lastScaleIndex >= 0) {
int tempSum = tempResult[lastScaleIndex] + carry;
if (tempSum >= org.apache.drill.exec.util.DecimalUtility.DIGITS_BASE) {
@@ -484,7 +351,7 @@ public class ${type.name}Functions {
lastScaleIndex--;
}
- // check if carry has increased integer digit
+ // Check if carry has increased integer digit
if ((lastScaleIndex + 1) < currentIndex) {
resultIntegerSize++;
currentIndex = lastScaleIndex + 1;
@@ -599,7 +466,7 @@ public class ${type.name}Functions {
out.buffer = in.buffer;
out.start = in.start;
- // set the output buffer with the positive sign
+ // Set the output buffer with the positive sign
out.buffer.setInt(out.start, (out.buffer.getInt(out.start) & 0x7fffffff));
}
}
@@ -691,7 +558,7 @@ public class ${type.name}Functions {
}
}
}
- // set the sign
+ // Set the sign
out.setSign(sign, out.start, out.buffer);
}
}
@@ -756,7 +623,7 @@ public class ${type.name}Functions {
}
}
}
- // set the sign
+ // Set the sign
out.setSign(sign, out.start, out.buffer);
}
}
@@ -790,8 +657,8 @@ public class ${type.name}Functions {
while (destIndex >= 0) {
out.setInteger(destIndex--, 0, out.start, out.buffer);
}
- // set the sign
- out.setSign(sign, out.start, out.buffer);
+ // Set the sign
+ out.setSign(sign, out.start, out.buffer);
}
}
@@ -867,8 +734,8 @@ public class ${type.name}Functions {
}
}
}
- // set the sign
- result.setSign(sign, result.start, result.buffer);
+ // Set the sign
+ result.setSign(sign, result.start, result.buffer);
}
}
@@ -929,8 +796,8 @@ public class ${type.name}Functions {
}
}
}
- // set the sign
- out.setSign(sign, out.start, out.buffer);
+ // Set the sign
+ out.setSign(sign, out.start, out.buffer);
}
}
@@ -952,26 +819,62 @@ public class ${type.name}Functions {
boolean sign = left.getSign(left.start, left.buffer);
org.apache.drill.exec.util.DecimalUtility.roundDecimal(result.buffer, result.start, result.nDecimalDigits, result.scale, left.scale);
- // set the sign
+ // Set the sign
result.setSign(sign, result.start, result.buffer);
}
}
- @FunctionTemplate(name = "compare_to", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
- public static class ${type.name}CompareTo implements DrillSimpleFunc {
+ <#-- Handle 2 x 2 combinations of nullable and non-nullable arguments. -->
+ <#list ["Nullable${type.name}", "${type.name}"] as leftType >
+ <#list ["Nullable${type.name}", "${type.name}"] as rightType >
- @Param ${type.name}Holder left;
- @Param ${type.name}Holder right;
- @Output IntHolder out;
- public void setup(RecordBatch incoming) {}
+ <#-- Comparison function for sorting and grouping relational operators
+ (not for comparison expression operators (=, <, etc.)). -->
+ @FunctionTemplate(name = FunctionGenerationHelper.COMPARE_TO_NULLS_HIGH,
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.INTERNAL)
+ public static class GCompare${leftType}Vs${rightType}NullHigh implements DrillSimpleFunc {
- public void eval() {
- <@compareBlock holderType=type.name left="left" right="right" absCompare="false" output="out.value"/>
- }
+ @Param ${leftType}Holder left;
+ @Param ${rightType}Holder right;
+ @Output IntHolder out;
+
+ public void setup(RecordBatch incoming) {}
+
+ public void eval() {
+ <@compareBlock leftType=leftType rightType=rightType absCompare="false" output="out.value" nullCompare=true nullComparesHigh=true />
}
+ }
- @FunctionTemplate(name = "less than", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+
+ <#-- Comparison function for sorting and grouping relational operators
+ (not for comparison expression operators (=, <, etc.)). -->
+ @FunctionTemplate(name = FunctionGenerationHelper.COMPARE_TO_NULLS_LOW,
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.INTERNAL)
+ public static class GCompare${leftType}Vs${rightType}NullLow implements DrillSimpleFunc {
+
+ @Param ${leftType}Holder left;
+ @Param ${rightType}Holder right;
+ @Output IntHolder out;
+
+ public void setup(RecordBatch incoming) {}
+
+ public void eval() {
+ <@compareBlock leftType=leftType rightType=rightType absCompare="false" output="out.value" nullCompare=true nullComparesHigh=false />
+ }
+ }
+
+ </#list>
+ </#list>
+
+
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "less than",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}LessThan implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -981,12 +884,19 @@ public class ${type.name}Functions {
public void eval() {
int cmp;
- <@compareBlock holderType=type.name left="left" right="right" absCompare="false" output="cmp"/>
+ <@compareBlock leftType="leftType" rightType="rightType" absCompare="false" output="cmp" nullCompare=false nullComparesHigh=false />
out.value = cmp == -1 ? 1 : 0;
}
}
- @FunctionTemplate(name = "less than or equal to", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+
+ // TODO: RESOLVE: Here there are spaces in function template names, but
+ // elsewhere there are underlines. Are things being looked up correctly?
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "less than or equal to",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}LessThanEq implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -996,12 +906,17 @@ public class ${type.name}Functions {
public void eval() {
int cmp;
- <@compareBlock holderType=type.name left="left" right="right" absCompare="false" output="cmp"/>
+ <@compareBlock leftType="leftType" rightType="rightType" absCompare="false" output="cmp" nullCompare=false nullComparesHigh=false />
out.value = cmp < 1 ? 1 : 0;
}
}
- @FunctionTemplate(name = "greater than", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "greater than",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}GreaterThan implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1011,12 +926,17 @@ public class ${type.name}Functions {
public void eval() {
int cmp;
- <@compareBlock holderType=type.name left="left" right="right" absCompare="false" output="cmp"/>
+ <@compareBlock leftType="leftType" rightType="rightType" absCompare="false" output="cmp" nullCompare=false nullComparesHigh=false />
out.value = cmp == 1 ? 1 : 0;
}
}
- @FunctionTemplate(name = "greater than or equal to", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "greater than or equal to",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}GreaterThanEq implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1026,12 +946,17 @@ public class ${type.name}Functions {
public void eval() {
int cmp;
- <@compareBlock holderType=type.name left="left" right="right" absCompare="false" output="cmp"/>
+ <@compareBlock leftType="leftType" rightType="rightType" absCompare="false" output="cmp" nullCompare=false nullComparesHigh=false />
out.value = cmp > -1 ? 1 : 0;
}
}
- @FunctionTemplate(name = "Equal", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "Equal",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}Equal implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1041,12 +966,17 @@ public class ${type.name}Functions {
public void eval() {
int cmp;
- <@compareBlock holderType=type.name left="left" right="right" absCompare="false" output="cmp"/>
+ <@compareBlock leftType="leftType" rightType="rightType" absCompare="false" output="cmp" nullCompare=false nullComparesHigh=false />
out.value = cmp == 0 ? 1 : 0;
}
}
- @FunctionTemplate(name = "not equal", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "not equal",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}NotEqual implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1056,13 +986,14 @@ public class ${type.name}Functions {
public void eval() {
int cmp;
- <@compareBlock holderType=type.name left="left" right="right" absCompare="false" output="cmp"/>
+ <@compareBlock leftType="leftType" rightType="rightType" absCompare="false" output="cmp" nullCompare=false nullComparesHigh=false />
out.value = cmp != 0 ? 1 : 0;
}
}
}
<#elseif type.name.endsWith("Dense")>
+
<@pp.changeOutputFile name="/org/apache/drill/exec/expr/fn/impl/${type.name}Functions.java" />
<#include "/@includes/license.ftl" />
@@ -1076,6 +1007,7 @@ import org.apache.drill.exec.expr.annotations.FunctionTemplate;
import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
import org.apache.drill.exec.expr.annotations.Output;
import org.apache.drill.exec.expr.annotations.Param;
+import org.apache.drill.exec.expr.fn.FunctionGenerationHelper;
import org.apache.drill.exec.expr.holders.*;
import org.apache.drill.exec.record.RecordBatch;
@@ -1087,20 +1019,65 @@ import java.nio.ByteBuffer;
public class ${type.name}Functions {
- @FunctionTemplate(name = "compare_to", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
- public static class ${type.name}CompareTo implements DrillSimpleFunc {
+ <#-- Handle 2 x 2 combinations of nullable and non-nullable arguments. -->
+ <#list ["Nullable${type.name}", "${type.name}"] as leftType >
+ <#list ["Nullable${type.name}", "${type.name}"] as rightType >
- @Param ${type.name}Holder left;
- @Param ${type.name}Holder right;
- @Output IntHolder out;
- public void setup(RecordBatch incoming) {}
+ <#-- Comparison function for sorting and grouping relational operators
+ (not for comparison expression operators (=, <, etc.)). -->
+ @FunctionTemplate(name = FunctionGenerationHelper.COMPARE_TO_NULLS_HIGH,
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.INTERNAL)
+ public static class GCompare${leftType}Vs${rightType}NullHigh implements DrillSimpleFunc {
- public void eval() {
- out.value = org.apache.drill.exec.util.DecimalUtility.compareDenseBytes(left.buffer, left.start, left.getSign(left.start, left.buffer), right.buffer, right.start, right.getSign(right.start, right.buffer), left.WIDTH);
- }
+ @Param ${leftType}Holder left;
+ @Param ${rightType}Holder right;
+ @Output IntHolder out;
+
+ public void setup(RecordBatch incoming) {}
+
+ public void eval() {
+ outside:
+ {
+ <@compareNullsSubblock leftType=leftType rightType=rightType output="out.value" breakTarget="outside" nullCompare=true nullComparesHigh=true />
+
+ out.value = org.apache.drill.exec.util.DecimalUtility.compareDenseBytes(left.buffer, left.start, left.getSign(left.start, left.buffer), right.buffer, right.start, right.getSign(right.start, right.buffer), left.WIDTH);
+ } // outside
+ }
+ }
+
+ <#-- Comparison function for sorting and grouping relational operators
+ (not for comparison expression operators (=, <, etc.)). -->
+ @FunctionTemplate(name = FunctionGenerationHelper.COMPARE_TO_NULLS_LOW,
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.INTERNAL)
+ public static class GCompare${leftType}Vs${rightType}NullLow implements DrillSimpleFunc {
+
+ @Param ${leftType}Holder left;
+ @Param ${rightType}Holder right;
+ @Output IntHolder out;
+
+ public void setup(RecordBatch incoming) {}
+
+ public void eval() {
+ outside:
+ {
+ <@compareNullsSubblock leftType=leftType rightType=rightType output="out.value" breakTarget="outside" nullCompare=true nullComparesHigh=false />
+
+ out.value = org.apache.drill.exec.util.DecimalUtility.compareDenseBytes(left.buffer, left.start, left.getSign(left.start, left.buffer), right.buffer, right.start, right.getSign(right.start, right.buffer), left.WIDTH);
+ } // outside
}
+ }
+
+ </#list>
+ </#list>
+
- @FunctionTemplate(name = "less than", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "less than",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}LessThan implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1114,7 +1091,11 @@ public class ${type.name}Functions {
}
}
- @FunctionTemplate(name = "less than or equal to", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "less than or equal to",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}LessThanEq implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1128,7 +1109,11 @@ public class ${type.name}Functions {
}
}
- @FunctionTemplate(name = "greater than", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "greater than",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}GreaterThan implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1142,7 +1127,11 @@ public class ${type.name}Functions {
}
}
- @FunctionTemplate(name = "greater than or equal to", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "greater than or equal to",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}GreaterThanEq implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1156,7 +1145,11 @@ public class ${type.name}Functions {
}
}
- @FunctionTemplate(name = "Equal", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "Equal",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}Equal implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1171,7 +1164,11 @@ public class ${type.name}Functions {
}
- @FunctionTemplate(name = "not equal", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "not equal",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}NotEqual implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1186,6 +1183,7 @@ public class ${type.name}Functions {
}
}
}
+
<#elseif type.name.endsWith("Decimal9") || type.name.endsWith("Decimal18")>
<@pp.changeOutputFile name="/org/apache/drill/exec/expr/fn/impl/${type.name}Functions.java" />
@@ -1202,6 +1200,7 @@ import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
import org.apache.drill.exec.expr.annotations.Output;
import org.apache.drill.exec.expr.annotations.Param;
import org.apache.drill.exec.expr.annotations.Workspace;
+import org.apache.drill.exec.expr.fn.FunctionGenerationHelper;
import org.apache.drill.exec.expr.holders.*;
import org.apache.drill.exec.record.RecordBatch;
@@ -1233,7 +1232,7 @@ public class ${type.name}Functions {
outputScale = resultScalePrec.getOutputScale();
outputPrecision = resultScalePrec.getOutputPrecision();
}
- <@adjustScale holderType=type.name javaType=type.storage left="left" right="right"/>
+ <@adjustScale javaType=type.storage leftType="leftType" rightType="rightType"/>
result.value = left.value + right.value;
result.precision = outputPrecision;
@@ -1261,7 +1260,7 @@ public class ${type.name}Functions {
outputScale = resultScalePrec.getOutputScale();
outputPrecision = resultScalePrec.getOutputPrecision();
}
- <@adjustScale holderType=type.name javaType=type.storage left="left" right="right"/>
+ <@adjustScale javaType=type.storage leftType="leftType" rightType="rightType"/>
result.value = left.value - right.value;
result.precision = outputPrecision;
@@ -1511,7 +1510,9 @@ public class ${type.name}Functions {
}
}
- @FunctionTemplate(name = "round", scope = FunctionTemplate.FunctionScope.DECIMAL_SET_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ @FunctionTemplate(name = "round",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_SET_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}RoundScaleFunction implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1562,21 +1563,65 @@ public class ${type.name}Functions {
}
}
- @FunctionTemplate(name = "compare_to", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
- public static class ${type.name}CompareTo implements DrillSimpleFunc {
+ <#-- Handle 2 x 2 combinations of nullable and non-nullable arguments. -->
+ <#list ["Nullable${type.name}", "${type.name}"] as leftType >
+ <#list ["Nullable${type.name}", "${type.name}"] as rightType >
- @Param ${type.name}Holder left;
- @Param ${type.name}Holder right;
- @Output IntHolder out;
- public void setup(RecordBatch incoming) {}
+ <#-- Comparison function for sorting and grouping relational operators
+ (not for comparison expression operators (=, <, etc.)). -->
+ @FunctionTemplate(name = FunctionGenerationHelper.COMPARE_TO_NULLS_HIGH,
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.INTERNAL)
+ public static class GCompare${leftType}Vs${rightType}NullHigh implements DrillSimpleFunc {
- public void eval() {
- <@adjustScale holderType=type.name javaType=type.storage left="left" right="right"/>
- out.value = (left.value < right.value) ? -1 : (left.value > right.value) ? 1 : 0;
- }
+ @Param ${leftType}Holder left;
+ @Param ${rightType}Holder right;
+ @Output IntHolder out;
+
+ public void setup(RecordBatch incoming) {}
+
+ public void eval() {
+ outside:
+ {
+ <@compareNullsSubblock leftType=leftType rightType=rightType output="out.value" breakTarget="outside" nullCompare=true nullComparesHigh=true />
+
+ <@adjustScale javaType=type.storage leftType="leftType" rightType="rightType"/>
+ out.value = (left.value < right.value) ? -1 : (left.value > right.value) ? 1 : 0;
+ } // outside
}
+ }
+
+ <#-- Comparison function for sorting and grouping relational operators
+ (not for comparison expression operators (=, <, etc.)). -->
+ @FunctionTemplate(name = FunctionGenerationHelper.COMPARE_TO_NULLS_LOW,
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.INTERNAL)
+ public static class GCompare${leftType}Vs${rightType}NullLow implements DrillSimpleFunc {
+
+ @Param ${leftType}Holder left;
+ @Param ${rightType}Holder right;
+ @Output IntHolder out;
+
+ public void setup(RecordBatch incoming) {}
+
+ public void eval() {
+ outside:
+ {
+ <@compareNullsSubblock leftType=leftType rightType=rightType output="out.value" breakTarget="outside" nullCompare=true nullComparesHigh=false />
+ <@adjustScale javaType=type.storage leftType="leftType" rightType="rightType"/>
+ out.value = (left.value < right.value) ? -1 : (left.value > right.value) ? 1 : 0;
+ } // outside
+ }
+ }
+
+ </#list>
+ </#list>
- @FunctionTemplate(name = "less than", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "less than",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}LessThan implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1585,13 +1630,16 @@ public class ${type.name}Functions {
public void setup(RecordBatch incoming) {}
public void eval() {
- int cmp;
- <@adjustScale holderType=type.name javaType=type.storage left="left" right="right"/>
+ <@adjustScale javaType=type.storage leftType="leftType" rightType="rightType"/>
out.value = (left.value < right.value) ? 1 : 0;
}
}
- @FunctionTemplate(name = "less than or equal to", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "less than or equal to",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}LessThanEq implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1600,13 +1648,16 @@ public class ${type.name}Functions {
public void setup(RecordBatch incoming) {}
public void eval() {
- int cmp;
- <@adjustScale holderType=type.name javaType=type.storage left="left" right="right"/>
+ <@adjustScale javaType=type.storage leftType="leftType" rightType="rightType"/>
out.value = (left.value <= right.value) ? 1 : 0;
}
}
- @FunctionTemplate(name = "greater than", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "greater than",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}GreaterThan implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1615,13 +1666,16 @@ public class ${type.name}Functions {
public void setup(RecordBatch incoming) {}
public void eval() {
- int cmp;
- <@adjustScale holderType=type.name javaType=type.storage left="left" right="right"/>
+ <@adjustScale javaType=type.storage leftType="leftType" rightType="rightType"/>
out.value = (left.value > right.value) ? 1 : 0;
}
}
- @FunctionTemplate(name = "greater than or equal to", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "greater than or equal to",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}GreaterThanEq implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1630,13 +1684,16 @@ public class ${type.name}Functions {
public void setup(RecordBatch incoming) {}
public void eval() {
- int cmp;
- <@adjustScale holderType=type.name javaType=type.storage left="left" right="right"/>
+ <@adjustScale javaType=type.storage leftType="leftType" rightType="rightType"/>
out.value = (left.value >= right.value) ? 1 : 0;
}
}
- @FunctionTemplate(name = "Equal", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "Equal",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}Equal implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1645,14 +1702,17 @@ public class ${type.name}Functions {
public void setup(RecordBatch incoming) {}
public void eval() {
- int cmp;
- <@adjustScale holderType=type.name javaType=type.storage left="left" right="right"/>
+ <@adjustScale javaType=type.storage leftType="leftType" rightType="rightType"/>
out.value = (left.value == right.value) ? 1 : 0;
}
}
- @FunctionTemplate(name = "not equal", scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE, nulls = NullHandling.NULL_IF_NULL)
+ <#-- Comparison function for comparison expression operator (=, <, etc.),
+ not for sorting and grouping relational operators.) -->
+ @FunctionTemplate(name = "not equal",
+ scope = FunctionTemplate.FunctionScope.DECIMAL_MAX_SCALE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class ${type.name}NotEqual implements DrillSimpleFunc {
@Param ${type.name}Holder left;
@@ -1661,13 +1721,12 @@ public class ${type.name}Functions {
public void setup(RecordBatch incoming) {}
public void eval() {
-
- int cmp;
- <@adjustScale holderType=type.name javaType=type.storage left="left" right="right"/>
+ <@adjustScale javaType=type.storage leftType="leftType" rightType="rightType"/>
out.value = (left.value != right.value) ? 1 : 0;
}
}
}
</#if>
-</#list>
\ No newline at end of file
+
+</#list>
http://git-wip-us.apache.org/repos/asf/drill/blob/5efc7e68/exec/java-exec/src/main/java/org/apache/drill/exec/client/PrintingResultsListener.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/client/PrintingResultsListener.java b/exec/java-exec/src/main/java/org/apache/drill/exec/client/PrintingResultsListener.java
index 1ed3cb3..926e703 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/client/PrintingResultsListener.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/client/PrintingResultsListener.java
@@ -53,6 +53,7 @@ public class PrintingResultsListener implements UserResultsListener {
@Override
public void submissionFailed(RpcException ex) {
exception = ex;
+ System.out.println("Exception (no rows returned): " + ex );
latch.countDown();
}
@@ -87,7 +88,7 @@ public class PrintingResultsListener implements UserResultsListener {
if (isLastChunk) {
allocator.close();
latch.countDown();
- System.out.println("Total rows returned : " + count.get());
+ System.out.println("Total rows returned: " + count.get());
}
}
http://git-wip-us.apache.org/repos/asf/drill/blob/5efc7e68/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
index e1ad854..3565bf4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
@@ -203,7 +203,7 @@ public class ExpressionTreeMaterializer {
List<LogicalExpression> args = Lists.newArrayList();
for (int i = 0; i < call.args.size(); ++i) {
LogicalExpression newExpr = call.args.get(i).accept(this, registry);
- assert newExpr != null : String.format("Materialization of %s return a null expression.", call.args.get(i));
+ assert newExpr != null : String.format("Materialization of %s returned a null expression.", call.args.get(i));
args.add(newExpr);
}
http://git-wip-us.apache.org/repos/asf/drill/blob/5efc7e68/exec/java-exec/src/main/java/org/apache/drill/exec/expr/annotations/FunctionTemplate.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/annotations/FunctionTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/annotations/FunctionTemplate.java
index 1f732a3..15c7e19 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/annotations/FunctionTemplate.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/annotations/FunctionTemplate.java
@@ -28,15 +28,27 @@ import java.lang.annotation.Target;
public @interface FunctionTemplate {
/**
- * Use this annotation if there is only one name for function
- * Note: If you use this annotation don't use {@link #names()}
+ * Name of function (when only one.)
+ * Use this annotation element if there is only one name for the function.
+ * Note: If you use this annotation don't use {@link #names()}.
+ * <p>
+ * TODO: Refer to wherever list of possible or at least known names is,
+ * to resolve the current issue of spaces vs. underlines in names (e.g., we
+ * have both "less_than" and "less than".
+ * </p>
* @return
*/
String name() default "";
/**
- * Use this annotation if there are multiple names for function
- * Note: If you use this annotation don't use {@link #name()}
+ * Names of function (when multiple).
+ * Use this annotation element if there are multiple names for the function.
+ * Note: If you use this annotation don't use {@link #name()}.
+ * <p>
+ * TODO: Refer to wherever list of possible or at least known names is,
+ * to resolve the current issue of spaces vs. underlines in names (e.g., we
+ * have both "less_than" and "less than".
+ * </p>
* @return
*/
String[] names() default {};
@@ -49,10 +61,21 @@ public @interface FunctionTemplate {
FunctionCostCategory costCategory() default FunctionCostCategory.SIMPLE;
public static enum NullHandling {
- INTERNAL, NULL_IF_NULL;
+ /**
+ * Method handles nulls.
+ */
+ INTERNAL,
+
+ /**
+ * Null output if any null input:
+ * Indicates that a method's associated logical operation returns NULL if
+ * either input is NULL, and therefore that the method must not be called
+ * with null inputs. (The calling framework must handle NULLs.)
+ */
+ NULL_IF_NULL;
}
- public static enum FunctionScope{
+ public static enum FunctionScope {
SIMPLE,
POINT_AGGREGATE,
DECIMAL_AGGREGATE,
http://git-wip-us.apache.org/repos/asf/drill/blob/5efc7e68/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionGenerationHelper.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionGenerationHelper.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionGenerationHelper.java
index d007d7c..19cd1d8 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionGenerationHelper.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionGenerationHelper.java
@@ -29,28 +29,58 @@ import org.apache.drill.common.types.TypeProtos.MinorType;
import org.apache.drill.common.types.Types;
import org.apache.drill.exec.expr.ClassGenerator.HoldingContainer;
import org.apache.drill.exec.expr.HoldingContainerExpression;
+import org.eigenbase.rel.RelFieldCollation.NullDirection;
public class FunctionGenerationHelper {
- public static final String COMPARE_TO = "compare_to";
+ public static final String COMPARE_TO_NULLS_HIGH = "compare_to_nulls_high";
+ public static final String COMPARE_TO_NULLS_LOW = "compare_to_nulls_low";
/**
- * Given materialized arguments find the "compare_to" FunctionHolderExpression
- * @param left
- * @param right
- * @param registry
- * @return FunctionHolderExpression containing the function implementation
+ * Finds ordering comparator ("compare_to...") FunctionHolderExpression with
+ * a specified ordering for NULL (and considering NULLS <i>equal</i>).
+ * @param null_high whether NULL should compare as the lowest value (if
+ * {@code false}) or the highest value (if {@code true})
+ * @param left ...
+ * @param right ...
+ * @param registry ...
+ * @return
+ * FunctionHolderExpression containing the found function implementation
*/
- public static FunctionHolderExpression getComparator(HoldingContainer left,
- HoldingContainer right,
- FunctionImplementationRegistry registry) {
- if (! isComparableType(left.getMajorType()) || ! isComparableType(right.getMajorType()) ){
- throw new UnsupportedOperationException(formatCanNotCompareMsg(left.getMajorType(), right.getMajorType()));
+ public static FunctionHolderExpression getOrderingComparator(
+ boolean null_high,
+ HoldingContainer left,
+ HoldingContainer right,
+ FunctionImplementationRegistry registry) {
+ final String comparator_name =
+ null_high ? COMPARE_TO_NULLS_HIGH : COMPARE_TO_NULLS_LOW;
+
+ if ( ! isComparableType(left.getMajorType() )
+ || ! isComparableType(right.getMajorType() ) ) {
+ throw new UnsupportedOperationException(
+ formatCanNotCompareMsg(left.getMajorType(), right.getMajorType()));
}
+ return getFunctionExpression(comparator_name, Types.required(MinorType.INT),
+ registry, left, right);
+ }
- return getFunctionExpression(COMPARE_TO, Types.required(MinorType.INT), registry, left, right);
+ /**
+ * Finds ordering comparator ("compare_to...") FunctionHolderExpression with
+ * a "NULL high" ordering (and considering NULLS <i>equal</i>).
+ * @param left ...
+ * @param right ...
+ * @param registry ...
+ * @return FunctionHolderExpression containing the function implementation
+ * @see #getComparator
+ */
+ public static FunctionHolderExpression getOrderingComparatorNullsHigh(
+ HoldingContainer left,
+ HoldingContainer right,
+ FunctionImplementationRegistry registry) {
+ return getOrderingComparator(true, left, right, registry);
}
- public static FunctionHolderExpression getFunctionExpression(String name, MajorType returnType, FunctionImplementationRegistry registry, HoldingContainer... args) {
+ public static FunctionHolderExpression getFunctionExpression(
+ String name, MajorType returnType, FunctionImplementationRegistry registry, HoldingContainer... args) {
List<MajorType> argTypes = new ArrayList<MajorType>(args.length);
List<LogicalExpression> argExpressions = new ArrayList<LogicalExpression>(args.length);
for(HoldingContainer c : args) {
@@ -69,10 +99,10 @@ public class FunctionGenerationHelper {
sb.append("( ");
for(int i =0; i < args.length; i++) {
MajorType mt = args[i].getMajorType();
- appendType(mt, sb);
if (i != 0) {
sb.append(", ");
}
+ appendType(mt, sb);
}
sb.append(" ) returns ");
appendType(returnType, sb);
http://git-wip-us.apache.org/repos/asf/drill/blob/5efc7e68/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionImplementationRegistry.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionImplementationRegistry.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionImplementationRegistry.java
index 25dcbbc..55e4121 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionImplementationRegistry.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionImplementationRegistry.java
@@ -99,11 +99,15 @@ public class FunctionImplementationRegistry {
return functionResolver.getBestMatch(drillFuncRegistry.getMethods(functionReplacement(functionCall)), functionCall);
}
- // Check if this Function Replacement is Needed; if yes, return a new name. otherwise, return the original name
+ // Check if this Function Replacement is needed; if yes, return a new name. otherwise, return the original name
private String functionReplacement(FunctionCall functionCall) {
String funcName = functionCall.getName();
- if(optionManager != null && optionManager.getOption(ExecConstants.CAST_TO_NULLABLE_NUMERIC).bool_val && CastFunctions.isReplacementNeeded(functionCall.args.get(0).getMajorType().getMinorType(), funcName)) {
- org.apache.drill.common.types.TypeProtos.DataMode dataMode = functionCall.args.get(0).getMajorType().getMode();
+ if (optionManager != null
+ && optionManager.getOption(ExecConstants.CAST_TO_NULLABLE_NUMERIC).bool_val
+ && CastFunctions.isReplacementNeeded(functionCall.args.get(0).getMajorType().getMinorType(),
+ funcName)) {
+ org.apache.drill.common.types.TypeProtos.DataMode dataMode =
+ functionCall.args.get(0).getMajorType().getMode();
funcName = CastFunctions.getReplacingCastFunction(funcName, dataMode);
}
http://git-wip-us.apache.org/repos/asf/drill/blob/5efc7e68/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BitFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BitFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BitFunctions.java
index 3fe489f..ae42872 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BitFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BitFunctions.java
@@ -27,9 +27,17 @@ import org.apache.drill.exec.expr.holders.BitHolder;
import org.apache.drill.exec.expr.holders.IntHolder;
import org.apache.drill.exec.record.RecordBatch;
+/**
+ * Function templates for Bit/BOOLEAN functions other than comparison
+ * functions. (Bit/BOOLEAN comparison functions are generated in
+ * ComparisonFunctions.java template.)
+ *
+ */
public class BitFunctions {
- @FunctionTemplate(names = {"booleanOr", "or", "||"}, scope = FunctionScope.SC_BOOLEAN_OPERATOR, nulls = NullHandling.NULL_IF_NULL)
+ @FunctionTemplate(names = {"booleanOr", "or", "||"},
+ scope = FunctionScope.SC_BOOLEAN_OPERATOR,
+ nulls = NullHandling.NULL_IF_NULL)
public static class BitOr implements DrillSimpleFunc {
@Param BitHolder left;
@@ -43,7 +51,9 @@ public class BitFunctions {
}
}
- @FunctionTemplate(names = {"booleanAnd", "and", "&&"}, scope = FunctionScope.SC_BOOLEAN_OPERATOR, nulls = NullHandling.NULL_IF_NULL)
+ @FunctionTemplate(names = {"booleanAnd", "and", "&&"},
+ scope = FunctionScope.SC_BOOLEAN_OPERATOR,
+ nulls = NullHandling.NULL_IF_NULL)
public static class BitAnd implements DrillSimpleFunc {
@Param BitHolder left;
@@ -58,7 +68,9 @@ public class BitFunctions {
}
- @FunctionTemplate(names = {"xor", "^"}, scope = FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
+ @FunctionTemplate(names = {"xor", "^"},
+ scope = FunctionScope.SIMPLE,
+ nulls = NullHandling.NULL_IF_NULL)
public static class IntXor implements DrillSimpleFunc {
@Param IntHolder left;
@@ -72,32 +84,4 @@ public class BitFunctions {
}
}
- @FunctionTemplate(names = {"equal","==","="}, scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
- public static class EqualsBitBit implements DrillSimpleFunc {
-
- @Param BitHolder left;
- @Param BitHolder right;
- @Output BitHolder out;
-
- public void setup(RecordBatch b) {}
-
- public void eval() {
- out.value = left.value == right.value ? 1 : 0;
-
- }
- }
-
- @FunctionTemplate(name = "compare_to", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
- public static class CompareBitBit implements DrillSimpleFunc {
-
- @Param BitHolder left;
- @Param BitHolder right;
- @Output IntHolder out;
-
- public void setup(RecordBatch b) {}
-
- public void eval() {
- out.value = left.value < right.value ? -1 : ((left.value == right.value)? 0 : 1);
- }
- }
}
http://git-wip-us.apache.org/repos/asf/drill/blob/5efc7e68/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ComparisonFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ComparisonFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ComparisonFunctions.java
deleted file mode 100644
index bf42ce6..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ComparisonFunctions.java
+++ /dev/null
@@ -1,572 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.drill.exec.expr.fn.impl;
-
-
-public class ComparisonFunctions {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(MathFunctions.class);
-
-// private ComparisonFunctions() {}
-//
-// @FunctionTemplate(name = "equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class IntEqual implements DrillSimpleFunc {
-//
-// @Param IntHolder left;
-// @Param IntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value == right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class BigIntEqual implements DrillSimpleFunc {
-//
-// @Param BigIntHolder left;
-// @Param BigIntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value == right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float4Equal implements DrillSimpleFunc {
-//
-// @Param Float4Holder left;
-// @Param Float4Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value == right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float8Equal implements DrillSimpleFunc {
-//
-// @Param Float8Holder left;
-// @Param Float8Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value == right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "not equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class IntNotEqual implements DrillSimpleFunc {
-//
-// @Param IntHolder left;
-// @Param IntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value != right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "not equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class BigIntNotEqual implements DrillSimpleFunc {
-//
-// @Param BigIntHolder left;
-// @Param BigIntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value != right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "not equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float4NotEqual implements DrillSimpleFunc {
-//
-// @Param Float4Holder left;
-// @Param Float4Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value != right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "not equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float8NotEqual implements DrillSimpleFunc {
-//
-// @Param Float8Holder left;
-// @Param Float8Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value != right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class IntGreaterThan implements DrillSimpleFunc {
-//
-// @Param IntHolder left;
-// @Param IntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value > right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class BigIntGreaterThan implements DrillSimpleFunc {
-//
-// @Param BigIntHolder left;
-// @Param BigIntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value > right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float4GreaterThan implements DrillSimpleFunc {
-//
-// @Param Float4Holder left;
-// @Param Float4Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value > right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float8GreaterThan implements DrillSimpleFunc {
-//
-// @Param Float8Holder left;
-// @Param Float8Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value > right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class IntGreaterThanEqual implements DrillSimpleFunc {
-//
-// @Param IntHolder left;
-// @Param IntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value >= right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class BigIntGreaterThanEqual implements DrillSimpleFunc {
-//
-// @Param BigIntHolder left;
-// @Param BigIntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value >= right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float4GreaterThanEqual implements DrillSimpleFunc {
-//
-// @Param Float4Holder left;
-// @Param Float4Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value >= right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float8GreaterThanEqual implements DrillSimpleFunc {
-//
-// @Param Float8Holder left;
-// @Param Float8Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value >= right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class IntLessThan implements DrillSimpleFunc {
-//
-// @Param IntHolder left;
-// @Param IntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value < right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class BigIntLessThan implements DrillSimpleFunc {
-//
-// @Param BigIntHolder left;
-// @Param BigIntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value < right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float4LessThan implements DrillSimpleFunc {
-//
-// @Param Float4Holder left;
-// @Param Float4Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value < right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float8LessThan implements DrillSimpleFunc {
-//
-// @Param Float8Holder left;
-// @Param Float8Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value < right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class IntLessThanEqual implements DrillSimpleFunc {
-//
-// @Param IntHolder left;
-// @Param IntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value <= right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class BigIntLessThanEqual implements DrillSimpleFunc {
-//
-// @Param BigIntHolder left;
-// @Param BigIntHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value <= right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float4LessThanEqual implements DrillSimpleFunc {
-//
-// @Param Float4Holder left;
-// @Param Float4Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value <= right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class Float8LessThanEqual implements DrillSimpleFunc {
-//
-// @Param Float8Holder left;
-// @Param Float8Holder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = (left.value <= right.value) ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarBinaryEqual implements DrillSimpleFunc {
-//
-// @Param VarBinaryHolder left;
-// @Param VarBinaryHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) == 0 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarCharEqual implements DrillSimpleFunc {
-//
-// @Param VarCharHolder left;
-// @Param VarCharHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) == 0 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "equal", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarBinaryCharEqual implements DrillSimpleFunc {
-//
-// @Param VarBinaryHolder left;
-// @Param VarCharHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) == 0 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarBinaryGTE implements DrillSimpleFunc {
-//
-// @Param VarBinaryHolder left;
-// @Param VarBinaryHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) > -1 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarCharGTE implements DrillSimpleFunc {
-//
-// @Param VarCharHolder left;
-// @Param VarCharHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) > -1 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarBinaryCharGTE implements DrillSimpleFunc {
-//
-// @Param VarBinaryHolder left;
-// @Param VarCharHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) > -1 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarBinaryGT implements DrillSimpleFunc {
-//
-// @Param VarBinaryHolder left;
-// @Param VarBinaryHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) == 1 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarCharGT implements DrillSimpleFunc {
-//
-// @Param VarCharHolder left;
-// @Param VarCharHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) == 1 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "greater than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarBinaryCharGT implements DrillSimpleFunc {
-//
-// @Param VarBinaryHolder left;
-// @Param VarCharHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) == 1? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarBinaryLTE implements DrillSimpleFunc {
-//
-// @Param VarBinaryHolder left;
-// @Param VarBinaryHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) < 1 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarCharLTE implements DrillSimpleFunc {
-//
-// @Param VarCharHolder left;
-// @Param VarCharHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) < 1 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than or equal to", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarBinaryCharLTE implements DrillSimpleFunc {
-//
-// @Param VarBinaryHolder left;
-// @Param VarCharHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) < 1? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarBinaryLT implements DrillSimpleFunc {
-//
-// @Param VarBinaryHolder left;
-// @Param VarBinaryHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) == -1 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarCharLT implements DrillSimpleFunc {
-//
-// @Param VarCharHolder left;
-// @Param VarCharHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) == -1 ? 1 : 0;
-// }
-// }
-//
-// @FunctionTemplate(name = "less than", scope = FunctionTemplate.FunctionScope.SIMPLE)
-// public static class VarBinaryCharLT implements DrillSimpleFunc {
-//
-// @Param VarBinaryHolder left;
-// @Param VarCharHolder right;
-// @Output BitHolder out;
-//
-// public void setup(RecordBatch b) {}
-//
-// public void eval() {
-// out.value = org.apache.drill.exec.expr.fn.impl.VarHelpers.compare(left, right) == -1 ? 1 : 0;
-// }
-// }
-
-}