The generated code for sql queries that filter on DATE, TIME or TIMESTAMP fields is incorrect.
The problem can easily be reproduced with the csv example using a statement such as (patch with unit test in attachment).
or (similar but not exactly the same problem)
In case of the not-null filter, the generated code contains
This seems to be generated in the assumption that the internal representation is a long, rather than a java.sql.Date, java.sql.Time or java.sql.Timestamp.
So first question: is the enumerator supposed to return java.sql.Date, java.sql.Time and java.sql.Timestamp values or simply longs (epoch millis). Currently it returns java.sql.* types and that is definitely how it used to work in older calcite versions.
In that case the generated code should probably not contain the internalToDate function?
However the mere existence of that function makes me think that maybe the enumerators are supposed to return long values. But in that case the generated code is also wrong, it should probably be (added cast):
With the second sql query (greater than filter), the generated code actually does contain a cast to Integer (which fails):
The cast fails with java.sql.Date cannot be cast to java.lang.Integer