calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Bortoli <stefano.bort...@huawei.com>
Subject RE: doubt about how to access a lowerbound value in window
Date Tue, 14 Feb 2017 01:06:49 GMT
Thanks a lot Julian for you answer. 

In the Windows.groups.lowerBound I get the InputRef object, that gives me the variable name,
say $4, and an index. However, I cannot find the value in the input using these references,
as the value for what I can see in the debugger, is just in the constants array. I am precisely
in the "between  2 preceding and current row" case. 

I was expecting to get the value in the input using the ref (either index or name) but I am
missing something I guess.

Stefano Bortoli

-----Original Message-----
From: Julian Hyde [mailto:jhyde@apache.org] 
Sent: Monday, February 13, 2017 8:13 PM
To: dev@calcite.apache.org
Subject: Re: doubt about how to access a lowerbound value in window

The Window.constants field exists for a corner case, namely expressions like ‘sum(123) over
w’.

The bounds, such as “10 rows preceding” or “range between ‘1’ hour preceding and
‘2’ minute following”, are inside Window.groups.lowerBound and .upperBound.

The best way to understand this is to write various SQL statements and see what comes out
of "explain plan without implementation for …” and "explain plan with implementation for
…”. IIRC, you won’t find LogicalWindow in the former (they are windowed aggregates will
be inside LogicalProject; the LogicalWindow hasn’t been created yet); and in the latter
you’ll see EnumerableWindow.

 
> On Feb 9, 2017, at 8:44 AM, Stefano Bortoli <stefano.bortoli@huawei.com> wrote:
> 
> But constants can contain more things. In my case, there are 2 objects for example.
> 
> What I am struggling with is to connect a variable name I get from the lowerbound with
its value. Perhaps it is something basic, but I cannot do it.
> 
> Any idea about how to do that?
> 
> Stefano
> 
> -----Original Message-----
> From: Γιώργος Θεοδωράκης [mailto:giwrgosrtheod@gmail.com]
> Sent: Thursday, February 09, 2017 3:01 PM
> To: dev@calcite.apache.org
> Subject: Re: doubt about how to access a lowerbound value in window
> 
> I try something like this:
> 
> Iterate until you find the your window rel and then
> 
> LogicalWindow windowAgg = (LogicalWindow) rel; int windowRange = 
> createWindowFrame(windowAgg.getConstants());
> 
> ...
> 
> private int createWindowFrame(List<RexLiteral> constants) { int 
> windowFrame = 0; for ( RexLiteral con : constants) windowFrame += 
> Integer.parseInt(con.toString()); // fix unbounded window range //if 
> (windowFrame == 0) // windowFrame++; return windowFrame; }
> 
> 2017-02-09 15:19 GMT+02:00 Stefano Bortoli <stefano.bortoli@huawei.com>:
> 
>> Hi all,
>> 
>> 
>> 
>> I am new to the community and I  am still figuring out things. So 
>> please, apologize if I am not precise enough.
>> 
>> 
>> 
>> I am trying to work with streaming windows, and I would need to 
>> access some values related to the boundaries of the window.
>> 
>> 
>> 
>> So far, the way I found was to use the window group keys, and use its 
>> first value to get a value from the window.constants lists.
>> 
>> **************
>> 
>> Integer lowerBoundKey = group.keys.asList().get(0);
>> 
>> Object lowerbound = constants.get(lowerBoundKey).getValue2();
>> 
>> **************
>> 
>> However, this method seems to be a little arbitrary as I would expect 
>> to be using the lowerbound offset somehow.
>> 
>> 
>> 
>> Intuitively, I was expecting to use the lowerbound offset name or 
>> index position to get the value from somewhere, but I am having 
>> problems understanding how. I feel I am missing something, and I 
>> would be grateful if someone can give me some hint about it.
>> 
>> Thanks a lot in advance!
>> Stefano
>> 
>> 

Mime
View raw message