You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2017/03/07 18:25:38 UTC

[jira] [Comment Edited] (CALCITE-1673) Query with ORDER BY or GROUP BY on TIMESTAMP column throws CompileException

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

Julian Hyde edited comment on CALCITE-1673 at 3/7/17 6:25 PM:
--------------------------------------------------------------

Hi Julian,
See if this fix is useful. new method in SqlFunctions.

{code}
public static java.sql.Timestamp internalToTimestamp(Object v) {
    if (v == null ) {
      return null;
    } else if ( v instanceof Timestamp ) {
      return (Timestamp)v;
    }
    throw new RuntimeException(" Invalid type, cannot convert " + v + " to " + Timestamp.class.getName());
  }
{code}

Please let me know if you are okay with this fix, so that shall create patch and pull request.


was (Author: gkairi):
Hi Julian,
See if this fix is useful. new method in SqlFunctions.
public static java.sql.Timestamp internalToTimestamp(Object v) {
    if (v == null ) {
      return null;
    } else if ( v instanceof Timestamp ) {
      return (Timestamp)v;
    }
    throw new RuntimeException(" Invalid type, cannot convert " + v + " to " + Timestamp.class.getName());
  }
Please let me know if you are okay with this fix, so that shall create patch and pull request.

> Query with ORDER BY or GROUP BY on TIMESTAMP column throws CompileException
> ---------------------------------------------------------------------------
>
>                 Key: CALCITE-1673
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1673
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.11.0
>            Reporter: Gangadhar Kairi
>            Assignee: Julian Hyde
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Getting below error while executing the 'order by' or 'group by' queries with timestamp data type column.
> {noformat}
> Caused by: org.codehaus.commons.compiler.CompileException: Line 11, Column 76: No applicable constructor/method found for actual parameters "java.lang.Object"; candidates are: "public static java.sql.Timestamp org.apache.calcite.runtime.SqlFunctions.internalToTimestamp(java.lang.Long)", "public static java.sql.Timestamp org.apache.calcite.runtime.SqlFunctions.internalToTimestamp(long)"
> {noformat}
> I could able to reproduce this problem in CsvTests. 
> Fire a test with query "select * from \"DATE\" order by \"JOINTIMES\"" you will see test failing with exception.
> Root cause and fix:
> The fix for this to overload the {{SqlFunctions.internalToTimestamp()}} to accept the timestamp or object and return timestamp value. I tested and it's working
> {noformat}
> Stack trace
> at org.apache.calcite.avatica.Helper.wrap(Helper.java:37)
> 	at org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:108)
> 	at org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.implement(CalcitePrepareImpl.java:1233)
> 	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:303)
> 	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:200)
> 	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:761)
> 	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:617)
> 	at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:587)
> 	at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:214)
> 	at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:595)
> 	at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:615)
> 	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:148)
> 	... 29 more
> Caused by: org.codehaus.commons.compiler.CompileException: Line 11, Column 76: No applicable constructor/method found for actual parameters "java.lang.Object"; candidates are: "public static java.sql.Timestamp org.apache.calcite.runtime.SqlFunctions.internalToTimestamp(java.lang.Long)", "public static java.sql.Timestamp org.apache.calcite.runtime.SqlFunctions.internalToTimestamp(long)"
> 	at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10092)
> 	at org.codehaus.janino.UnitCompiler.findMostSpecificIInvocable(UnitCompiler.java:7506)
> 	at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:7376)
> 	at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:7280)
> 	at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3850)
> 	at org.codehaus.janino.UnitCompiler.access$6900(UnitCompiler.java:183)
> 	at org.codehaus.janino.UnitCompiler$10.visitMethodInvocation(UnitCompiler.java:3251)
> 	at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
> 	at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:3278)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)