[
https://issues.apache.org/jira/browse/TAJO-1415?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14519453#comment-14519453
]
ASF GitHub Bot commented on TAJO-1415:
--------------------------------------
Github user jihoonson commented on the pull request:
https://github.com/apache/tajo/pull/454#issuecomment-97451967
Thanks @sirpkt, but query results are still different.
Would you check it again?
**Tajo**
```
default> select l_partkey, l_tax, first_value(l_linestatus) over (partition
by l_partkey order by l_tax rows between 5 preceding and 8 following) from
lineitem;
l_partkey, l_tax, ?windowfunction
-------------------------------
1, 0.0, F
1, 0.0, F
1, 0.01, F
1, 0.01, F
1, 0.01, F
1, 0.02, F
1, 0.02, O
1, 0.02, F
1, 0.03, O
1, 0.03, F
1, 0.04, F
1, 0.04, O
1, 0.05, F
1, 0.05, F
1, 0.06, F
1, 0.06, O
1, 0.06, O
1, 0.06, F
1, 0.06, F
1, 0.07, F
1, 0.07, O
1, 0.07, F
1, 0.07, F
1, 0.07, O
1, 0.07, O
1, 0.08, F
1, 0.08, O
1, 0.08, F
1, 0.08, F
1, 0.08, F
1, 0.08, F
2, 0.0, O
2, 0.0, O
2, 0.0, O
2, 0.01, O
2, 0.01, O
...
```
**PostgreSQL**
```
jihoonson=# select l_partkey, l_tax, first_value(l_linestatus) over
(partition by l_partkey order by l_tax rows between 5 preceding and 8
following) from lineitem;
l_partkey | l_tax | first_value
-----------+-------+-------------
1 | 0 | O
1 | 0 | O
1 | 0.01 | O
1 | 0.01 | O
1 | 0.01 | O
1 | 0.02 | O
1 | 0.02 | F
1 | 0.02 | O
1 | 0.03 | F
1 | 0.03 | F
1 | 0.04 | F
1 | 0.04 | F
1 | 0.05 | O
1 | 0.05 | F
1 | 0.06 | F
1 | 0.06 | O
1 | 0.06 | O
1 | 0.06 | F
1 | 0.06 | F
1 | 0.07 | F
1 | 0.07 | F
1 | 0.07 | F
1 | 0.07 | O
1 | 0.07 | O
1 | 0.07 | O
1 | 0.08 | F
1 | 0.08 | O
1 | 0.08 | F
1 | 0.08 | F
1 | 0.08 | F
1 | 0.08 | O
2 | 0 | O
2 | 0 | O
2 | 0 | O
2 | 0.01 | O
2 | 0.01 | O
2 | 0.01 | O
2 | 0.02 | O
2 | 0.02 | O
2 | 0.02 | O
...
```
> Window frame support
> --------------------
>
> Key: TAJO-1415
> URL: https://issues.apache.org/jira/browse/TAJO-1415
> Project: Tajo
> Issue Type: Sub-task
> Components: distributed query plan, parser, physical operator,
> planner/optimizer
> Reporter: Keuntae Park
> Assignee: Keuntae Park
> Fix For: window function
>
>
> We can define frame clause in window definition like
> {code}
> [ RANGE | ROWS ] frame_start
> [ RANGE | ROWS ] BETWEEN frame_start AND frame_end
> {code}
> , where frame_start and frame_end can be one of
> {code}
> UNBOUNDED PRECEDING
> value PRECEDING
> CURRENT ROW
> value FOLLOWING
> UNBOUNDED FOLLOWING
> {code}
> According to the window functions description of
> PostgreSQL(http://www.postgresql.org/docs/9.4/static/functions-window.html),
> there are two types of window functions based on window frame support.
> 1) row_number, rank, dense_rank, percent_rank, cume_dist, tile, lag and lead:
> these functions only work within window partition, which means window frame
> has no effect on these functions.
> 2) first_value, last_value, nth_value, and aggregation function as as window
> function: these functions should work with rows within window frame.
> Currently, Tajo parser recognize the window frame grammar but windowAggExec
> does not use that information.
> It works as if window frame is set as "RANGE BETWEEN UNBOUND PROCEEDING AND
> UNBOUNDED FOLLOWING", which is different from the default window frame
> setting of most DBMSs "RANGE BETWEEN UNBOUND PROCEEDING AND CURRENT ROW".
> Following should be done:
> 1) Applying correct default window frame for first_value, last_value,
> nth_value, and aggregation functions .
> 2) Supporting various window frame expressions.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)