You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Shuyi Chen <su...@gmail.com> on 2018/08/24 00:50:37 UTC

Casting from BIGINT to TIMESTAMP in Calcite?

Currently, SqlValidator does not allow casting from BIGINT to TIMESTAMP. Is
there any reason that we don't support such CAST rule, or it is fine that
we add it in Calcite? Thanks a lot.

Shuyi
-- 
"So you have to trust that the dots will somehow connect in your future."

Re: Casting from BIGINT to TIMESTAMP in Calcite?

Posted by Julian Hyde <jh...@apache.org>.
I bet the semantics you have in mind makes some reference to the 1970-01-01 UNIX epoch. The SQL standard makes no mention of that epoch.

Converting numbers to timestamps is “obvious” only in that frame.

I don’t think it’s “obvious” enough for it to be the behavior of CAST. If you want to convert, use a conversion function (I’m sure Postgres has one) or interval arithmetic:

  Ts = TIMESTAMP ‘1970-01-01 00:00:00’ + m * INTERVAL ‘0.001’ SECOND

Julian


> On Aug 23, 2018, at 5:50 PM, Shuyi Chen <su...@gmail.com> wrote:
> 
> Currently, SqlValidator does not allow casting from BIGINT to TIMESTAMP. Is
> there any reason that we don't support such CAST rule, or it is fine that
> we add it in Calcite? Thanks a lot.
> 
> Shuyi
> -- 
> "So you have to trust that the dots will somehow connect in your future."