[ 
https://issues.apache.org/jira/browse/CALCITE-3563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16988423#comment-16988423
 ] 

Feng Zhu commented on CALCITE-3563:
-----------------------------------

Hi [~julianhyde], it is just an illustrative example.

We can also figure out some other cases like:
{code:java}
@Test public void test0() {
  final String sql = "SELECT round(1.5, cast(1 as bigint))";
  CalciteAssert.that()
      .query(sql)
      .returns("EXPR$0=1.5\n");
}
{code}
Exception:
{code:java}
java.lang.RuntimeException: while resolving method 'sround[class 
java.math.BigDecimal, long]' in class class 
org.apache.calcite.runtime.SqlFunctions
{code}
Since it is the argurments types are illegal, shall we make strict check in 
validation phase before entring into runtime?

 

> Convert function operand type to match implementation if necessary in runtime
> -----------------------------------------------------------------------------
>
>                 Key: CALCITE-3563
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3563
>             Project: Calcite
>          Issue Type: Sub-task
>          Components: core
>            Reporter: Feng Zhu
>            Assignee: Feng Zhu
>            Priority: Major
>
> Sub-task targets on following issue.
>  
> (1)Validation phase allows a wide range of operand types, but the runtime 
> implementation does not cover all cases.
>  For example, _*SqlFunction(MOD)*_ adopts 
> _*OperandTypes.EXACT_NUMERIC_EXACT_NUMERIC*_.
> {code:java}
> @Test public void test0() {
>  final String sql = "SELECT mod(12.5, cast(1 as bigint))";
>  CalciteAssert.that()
>  .query(sql)
>  .returns("EXPR$0=0.5\n");
>  }{code}
> We will get:
> {code:java}
> java.lang.RuntimeException: while resolving method 'mod[class 
> java.math.BigDecimal, long]' in class class 
> org.apache.calcite.runtime.SqlFunctions
>  at org.apache.calcite.linq4j.tree.Types.lookupMethod(Types.java:323)
>  at org.apache.calcite.linq4j.tree.Expressions.call(Expressions.java:445)
>  at 
> org.apache.calcite.adapter.enumerable.RexImpTable$MethodNameImplementor.implement(RexImpTable.java:2253)
>  at 
> org.apache.calcite.adapter.enumerable.RexImpTable.implementCall(RexImpTable.java:1195){code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to