Hi Julian,
Thanks a lot for your response. However, I still have two questions
(1) will milliseconds be enough? Hive would like to support nanoseconds and
Vertica also supports microseconds
https://my.vertica.com/docs/5.0/HTML/Master/9255.htm
Thus, the internal representation may be better decided by user himself
rather than fixed at milliseconds?
(2) How about the other way for casting, i.e., casting char to an interval?
select interval_day_time('2 1:2:3') from src limit 1;
For example, Hive will translate this into a RexLiteral of
176523000.000000, which is the millisecond representation of "2 1:2:3".
Then when it goes through the ReduceExpressionRule, RexReplacer will call
RexBuilder to make a cast. And in the L527 of RexBuilder, the value of
176523000.000000 will be divided by the multiplier and becomes the new
value. However, Hive does not want any multiplier as it is already in
millisecond format... Or is there any way to specify the multiplier as 1?
Thanks.
Best
Pengcheng
On Wed, Dec 9, 2015 at 2:18 PM, Julian Hyde <[email protected]> wrote:
> What would you expect the following to yield?
>
> VALUES CAST(INTERVAL '3' HOUR AS INTEGER)
>
> Like all intervals (except year-month intervals) the interval is
> internally represented in milliseconds, in this case 10,800,000, but
> when converted to a string or a numeric it is measured in hours, i.e.
> 3.
>
> Julian
>
>
> On Wed, Dec 9, 2015 at 2:05 PM, Pengcheng Xiong <[email protected]> wrote:
> > Hi all,
> >
> > While I was trying to debug something in Hive, I found some code in
> > RexBuilder which makes me confused.
> >
> > L527 it says
> >
> > {code}
> >
> > final long multiplier =
> >
> > literal.getType().getIntervalQualifier().getStartUnit()
> >
> > .multiplier;
> > {code}
> >
> > I saw it was committed
> >
> > commit 45b58ab07223cbb94c7cbbb9a1434a2b01a9497f
> > Author: julianhyde <[email protected]>
> > Date: Tue Jan 7 14:57:17 2014 -0800
> >
> > Reformat org.eigenbase code.
> >
> > Could Julian or someone explain how this multiplier is used? It looks
> > to me that it is redundant. I do not need that multiplier and "value"
> > itself is enough. Thanks!
> >
> > Best
> > Pengcheng
>