package com.taobao.tddl.executor.function.scalar; import com.taobao.tddl.executor.function.ScalarFunction; import com.taobao.tddl.optimizer.core.datatype.DataType; import com.taobao.tddl.optimizer.core.datatype.DataTypeUtil; import com.taobao.tddl.optimizer.core.expression.ISelectable; /** * @since 5.0.0 */ public class Add extends ScalarFunction { private Object computeInner(Object[] args) { DataType type = this.getReturnType(); return type.getCalculator().add(args[0], args[1]); } @Override public void compute(Object[] args) { result = this.computeInner(args); } @Override public DataType getReturnType() { Object[] args = function.getArgs().toArray(); DataType type = null; if (args[0] instanceof ISelectable) { type = ((ISelectable) args[0]).getDataType(); } if (type == null) { type = DataTypeUtil.getTypeOfObject(args[0]); } return type; } }