You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Danny Chen (Jira)" <ji...@apache.org> on 2019/12/07 06:01:00 UTC

[jira] [Resolved] (CALCITE-3565) Explicitly cast assignable operand types to decimal for udf

     [ https://issues.apache.org/jira/browse/CALCITE-3565?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Danny Chen resolved CALCITE-3565.
---------------------------------
    Resolution: Fixed

Fixed in [d934d12|https://github.com/apache/calcite/commit/d934d121077f271331810827ce9cf7ccb5d4768e], thanks for your PR, [~donnyzone] !

> Explicitly cast assignable operand types to decimal for udf
> -----------------------------------------------------------
>
>                 Key: CALCITE-3565
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3565
>             Project: Calcite
>          Issue Type: Sub-task
>          Components: core
>            Reporter: Feng Zhu
>            Assignee: Feng Zhu
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
>  Type is assignable conceptually, but in the runtime phase, explicite cast is still required.
>  For example, according to _*SqlTypeAssignmentRules*_, *_ST_MakePoint(Decimal, Decimal)_* also accepts operands with (_Integer_, _Decimal_) types, because Decimal is assignable from Integer.
> {code:java}
>   @Test public void test1() {
>     final String sql = "SELECT ST_MakePoint(1, 2.1)";
>     CalciteAssert.that()
>         .with(CalciteAssert.Config.GEO)
>         .query(sql)
>         .returns("EXPR$0={\"x\":1,\"y\":2.1}\n");
>   }
> {code}
> We will get:
> {code:java}
> org.codehaus.commons.compiler.CompileException: Line 22, Column 124: No applicable constructor/method found for actual parameters "int, java.math.BigDecimal"; candidates are: "public static org.apache.calcite.runtime.GeoFunctions$Geom org.apache.calcite.runtime.GeoFunctions.ST_MakePoint(java.math.BigDecimal, java.math.BigDecimal, java.math.BigDecimal)", "public static org.apache.calcite.runtime.GeoFunctions$Geom org.apache.calcite.runtime.GeoFunctions.ST_MakePoint(java.math.BigDecimal, java.math.BigDecimal)"
>  at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:12211)
>  at org.codehaus.janino.UnitCompiler.findMostSpecificIInvocable(UnitCompiler.java:9263)
>  at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:9123)
>  at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:9025)
>  at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:5062)
>  at org.codehaus.janino.UnitCompiler.access$9100(UnitCompiler.java:215){code}
>  



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