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

Switch to Threaded View
Drill, mail # dev - Exception while implementing drill trigonometric functions (For DRILL-219). Need tips.


Copy link to this message
-
Exception while implementing drill trigonometric functions (For DRILL-219). Need tips.
Yash Sharma 2013-09-08, 11:42
Hi All,
I have added few trigonometric for drill's math functions but am ending with the below exception when trying to use it in query. I have implemented these new functions exactly same as the floor/ceil functions (which i implemented previously). Floor and ceil are working correctly as expected.
Can anyone throw some tips on what i am messing up here?

Also adding the diff file for reference.
##################### SQLLINE EXCEPTION #################
0: jdbc:drill:schema=parquet-local> SELECT sin(2.75) FROM "sample-data/region.parquet";

Sep 08, 2013 4:57:40 PM org.eigenbase.sql.validate.SqlValidatorException <init>
SEVERE: org.eigenbase.sql.validate.SqlValidatorException: No match found for function signature SIN(<NUMERIC>)
Sep 08, 2013 4:57:40 PM org.eigenbase.util.EigenbaseException <init>
SEVERE: org.eigenbase.util.EigenbaseContextException: From line 1, column 8 to line 1, column 16
org.eigenbase.util.EigenbaseContextException: From line 1, column 8 to line 1, column 16
        at org.eigenbase.resource.EigenbaseResource$_Def12.ex(EigenbaseResource.java:1026)
        at org.eigenbase.sql.SqlUtil.newContextException(SqlUtil.java:739)
        at org.eigenbase.sql.SqlUtil.newContextException(SqlUtil.java:726)
        at org.eigenbase.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:3830)
        at org.eigenbase.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1594)
        at org.eigenbase.sql.SqlFunction.deriveType(SqlFunction.java:312)
        at org.eigenbase.sql.SqlFunction.deriveType(SqlFunction.java:222)
        at org.eigenbase.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:4238)
        at org.eigenbase.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:4220)
        at org.eigenbase.sql.SqlCall.accept(SqlCall.java:187)
        at org.eigenbase.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1502)
        at org.eigenbase.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1484)
        at org.eigenbase.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:435)
        at org.eigenbase.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:3290)
        at org.eigenbase.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3026)
        at org.eigenbase.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:69)
        at org.eigenbase.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:90)
        at org.eigenbase.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:802)
        at org.eigenbase.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:790)
        at org.eigenbase.sql.SqlSelect.validate(SqlSelect.java:154)
        at org.eigenbase.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:753)
        at org.eigenbase.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:444)
        at org.eigenbase.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:445)
        at net.hydromatic.optiq.prepare.Prepare.prepareSql(Prepare.java:160)
        at net.hydromatic.optiq.prepare.Prepare.prepareSql(Prepare.java:129)
        at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare2_(OptiqPrepareImpl.java:255)
        at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare_(OptiqPrepareImpl.java:195)
        at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepareSql(OptiqPrepareImpl.java:168)
        at net.hydromatic.optiq.jdbc.OptiqStatement.parseQuery(OptiqStatement.java:402)
        at net.hydromatic.optiq.jdbc.OptiqStatement.execute(OptiqStatement.java:192)
        at sqlline.SqlLine$Commands.execute(SqlLine.java:3825)
        at sqlline.SqlLine$Commands.sql(SqlLine.java:3738)
        at sqlline.SqlLine.dispatch(SqlLine.java:882)
        at sqlline.SqlLine.begin(SqlLine.java:717)
        at sqlline.SqlLine.mainWithInputRedirection(SqlLine.java:460)
        at sqlline.SqlLine.main(SqlLine.java:443)
Caused by: org.eigenbase.sql.validate.SqlValidatorException: No match found for function signature SIN(<NUMERIC>)
        at org.eigenbase.resource.EigenbaseResource$_Def9.ex(EigenbaseResource.java:963)
        ... 32 more

##################### DIFF #################
diff --git a/common/src/main/java/org/apache/drill/common/expression/fn/MathFunctions.java b/common/src/main/java/org/apache/drill/common/expression/fn/MathFunctions.java
index b1e1b67..34a1a4a 100644
+++ b/common/src/main/java/org/apache/drill/common/expression/fn/MathFunctions.java
@@ -17,10 +17,14 @@
  ******************************************************************************/
 package org.apache.drill.common.expression.fn;

+import org.apache.drill.common.expression.Arg;
 import org.apache.drill.common.expression.ArgumentValidators;
+import org.apache.drill.common.expression.BasicArgumentValidator;
 import org.apache.drill.common.expression.FunctionDefinition;
 import org.apache.drill.common.expression.CallProvider;
 import org.apache.drill.common.expression.OutputTypeDeterminer;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.Types;

@@ -35,7 +39,19 @@ public class MathFunctions implements CallProvider{
         FunctionDefinition.operator("divide", new ArgumentValidators.NumericTypeAllowed(1, Integer.MAX_VALUE, true), new OutputTypeDeterminer.SameAsAnySoft(), "/"),
         FunctionDefinition.operator("multiply", new ArgumentValidators.NumericTypeAllowed(1, Integer.MAX_VALUE, true), new OutputTypeDeterminer.SameAsAnySoft(), "*"),
         FunctionDefinition.operator("modulo", new ArgumentValidators.NumericTypeAllowed(1, Integer.MAX_VALUE, true), new OutputTypeDeterminer.SameAsAnySoft(), "%"),
-        XOR
+        XOR,
+        FunctionDefinition.simple("floatfloor", new BasicArgumentValidator(new Arg(Types.required(TypeProtos.MinorType.FLOAT8))), new OutputTypeDeterminer.SameAsFirstInput(), "