You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Jess Balint <jb...@gmail.com> on 2019/10/04 15:26:33 UTC

how to return dates in java/enumerable convention?

I'm returning string objects from my enumerable, but getting an exception
when trying to use the MONTH function which compiles to:


org.apache.calcite.avatica.util.DateTimeUtils.unixDateExtract(org.apache.calcite.avatica.util.TimeUnitRange.MONTH,
org.apache.calcite.runtime.SqlFunctions.toInt(current[1]))};

current[1] is a string here and an exception is thrown. are dates expected
to be java.util.Date objects? Is there documentation on this?

Thanks.

Jess

Re: how to return dates in java/enumerable convention?

Posted by Danny Chan <yu...@gmail.com>.
>In most cases the internal representation of date objects in the Enumerable
>convention are longs [1].

For the reference you give, date object is Integer internal instead of long.

Best,
Danny Chan
在 2019年10月6日 +0800 PM2:57,dev@calcite.apache.org,写道:
>
> In most cases the internal representation of date objects in the Enumerable
> convention are longs [1].

Re: how to return dates in java/enumerable convention?

Posted by Stamatis Zampetakis <za...@gmail.com>.
Hi Jess,

In most cases the internal representation of date objects in the Enumerable
convention are longs [1].
Keep in mind that there are also other cases (e.g., [2]) where there are
conversion of dates to other types.

Best,
Stamatis

[1]
https://github.com/apache/calcite/blob/35c5f57d7db2b4745086178602ca69195ffb858e/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java#L193
[2]
https://github.com/apache/calcite/blob/35c5f57d7db2b4745086178602ca69195ffb858e/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumUtils.java#L243


On Fri, Oct 4, 2019 at 5:26 PM Jess Balint <jb...@gmail.com> wrote:

> I'm returning string objects from my enumerable, but getting an exception
> when trying to use the MONTH function which compiles to:
>
>
>
> org.apache.calcite.avatica.util.DateTimeUtils.unixDateExtract(org.apache.calcite.avatica.util.TimeUnitRange.MONTH,
> org.apache.calcite.runtime.SqlFunctions.toInt(current[1]))};
>
> current[1] is a string here and an exception is thrown. are dates expected
> to be java.util.Date objects? Is there documentation on this?
>
> Thanks.
>
> Jess
>