Github user vvysotskyi commented on a diff in the pull request: https://github.com/apache/drill/pull/570#discussion_r160939410 --- Diff: exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java --- @@ -102,7 +111,578 @@ <#-- For each DECIMAL... type (in DecimalTypes.tdd) ... --> <#list comparisonTypesDecimal.decimalTypes as type> -<#if type.name.endsWith("Sparse")> +<#if type.name.endsWith("VarDecimal")> + +<@pp.changeOutputFile name="/org/apache/drill/exec/expr/fn/impl/${type.name}Functions.java" /> + +<#include "/@includes/license.ftl" /> + +package org.apache.drill.exec.expr.fn.impl; + +<#include "/@includes/vv_imports.ftl" /> + +import org.apache.drill.exec.expr.DrillSimpleFunc; +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.annotations.Workspace; +import org.apache.drill.exec.expr.fn.FunctionGenerationHelper; +import org.apache.drill.exec.expr.holders.*; +import org.apache.drill.exec.record.RecordBatch; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.DrillBuf; + +import java.nio.ByteBuffer; + +@SuppressWarnings("unused") +public class ${type.name}Functions { + private static void initBuffer(DrillBuf buffer) { + // for VarDecimal, this method of setting initial size is actually only a very rough heuristic. + int size = (${type.storage} * (org.apache.drill.exec.util.DecimalUtility.INTEGER_SIZE)); + buffer = buffer.reallocIfNeeded(size); + } + + @FunctionTemplate(name = "subtract", scope = FunctionTemplate.FunctionScope.DECIMAL_ADD_SCALE, nulls = NullHandling.NULL_IF_NULL) --- End diff -- By default `checkPrecision` is false, so it is not required to specify it explicitly in this case.
---