calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Droopy Hoo <olap...@gmail.com>
Subject Re: question about implement a scalarFunction whose argument type is date or timestamp
Date Wed, 09 Dec 2015 08:35:02 GMT
now the null value of Date or Timestamp type columns could not be queried.

the runtime exception is  cannot convert null to long

Using Integer or Long to represent Date and Timestamp may be a better
choice?

2015-11-20 4:41 GMT+08:00 Julian Hyde <jhyde@apache.org>:

> You are definitely seeing a bug. You should be able to define a UDF with a
> java.sql.Date argument and have Calcite call it.
>
> I think the cause is that Calcite uses int internally to represent dates,
> and it is not correctly inserting code to translate int to Date. You have
> discovered a clever workaround — Calcite sees the Date version of your
> function, and knows that the parameter type is a SQL DATE, then generates
> code that uses the int version of the function.
>
> Can you please log a bug for this? We will try to fix for 1.6.
>
> Julian
>
>
> > On Nov 19, 2015, at 12:29 AM, DroopyHoo <olaphoo@gmail.com> wrote:
> >
> > Hi,
> >
> > I have met a problem when using calcite 1.4 to implement a
> scalarFunction for my udf.
> >
> > the field type is date  and I want to realize the MY_FUNC(date)
> >
> > *SQL : select MY_FUNC(date)  from table;*
> >
> > if I set my function's argument type to java.sql.Date, calcite will
> report Exception:
> >
> > _/Caused by: org.codehaus.commons.compiler.CompileException: Line 124,
> Column 45: No applicable constructor/method found for actual parameters
> "int"; /_
> >
> >
> > if I set the function's argument type to  int, calcite will report
> Exception:
> >
> > _/Caused by: org.apache.calcite.sql.validate.SqlValidatorException: No
> match found for function signature MY_FUNCTION(<DATE>)/_
> >
> >
> > In my opinion, Now, I implement both two functions (one the arg type is
> int, other's is Date ), and it can work, but I think whether there is
> another better choice ?  By the way , is date type must be transformed to
> integer type when process the query ?
> >
> > --
> > -------
> > Wei Hu
> >
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message