calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sanjay Prasad <sanjay.pra...@kalkitech.in>
Subject Issue with date literal in where clause
Date Tue, 05 Apr 2016 04:36:03 GMT
Hi Guys,
           I am using calcite 1.7 to issue this query against a custom 
table that I have registered :

     PreparedStatement statement = calConn.prepareStatement(
             "select * from \"employee\" \"e\" where \"join_date\" < {d 
'1990-01-01'}");

     This gives me a runtime error like:

Caused by: java.lang.ClassCastException: java.sql.Date cannot be cast to 
java.lang.Integer
     at Baz$1$1.moveNext(Unknown Source)
     at 
org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.<init>(Linq4j.java:664)
     at org.apache.calcite.linq4j.Linq4j.enumeratorIterator(Linq4j.java:98)
     at 
org.apache.calcite.linq4j.AbstractEnumerable.iterator(AbstractEnumerable.java:33)
     at org.apache.calcite.avatica.MetaImpl.createCursor(MetaImpl.java:85)
     at 
org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:190)
     at 
org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:65)
     at 
org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:44)
     at 
org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:498)

     Changing the query to use a DATE literal does not help either (it 
gives the same error):

     PreparedStatement statement = calConn.prepareStatement(
             "select * from \"employee\" \"e\" where \"join_date\" < 
DATE '1990-01-01'");

     The registered table uses sql date as the data type:

public class JsonTable extends AbstractTable implements ScannableTable
{
     public RelDataType getRowType(RelDataTypeFactory typeFactory)
     {
         List<RelDataType> fields = new LinkedList<>();
         fields.add(typeFactory.createJavaType(String.class));
         fields.add(typeFactory.createJavaType(String.class));
         fields.add(typeFactory.createJavaType(Float.class));
         fields.add(typeFactory.createJavaType(java.sql.Date.class));

         return typeFactory.createStructType(fields, Arrays.asList("name",
             "city", "salary", "join_date"));
     }

     What am I doing wrong?

-Regards
-SP
"Disclaimer: This message is being sent from Kalki Communication Technologies
Pvt Ltd (KALKITECH). and may contain information which is confidential or 

privileged. If you are not the intended recipient, please advise the sender
immediately by reply e-mail and delete this message and any attachments 

without retaining a copy. Any unauthorized use of the content of this message
can expose the responsible party to civil and/or criminal penalties, 

and may constitute a more serious offense. Further the company does not accept
liability for any errors, omissions, viruses or computer problems 

experienced as a result of this transmission. If you have received this
message in error, notice is hereby given that no representation, contract or 

other binding obligation shall be created by this e-mail." 

Mime
View raw message