[ 
https://issues.apache.org/jira/browse/CALCITE-4661?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17376024#comment-17376024
 ] 

Julian Hyde commented on CALCITE-4661:
--------------------------------------

The PR looks very good. I've marked 'fix in 1.28' so that we don't drop this. A 
few things:
* Does MODE need to reserved?  Does it even need to be a keyword? I think this 
change could be accomplished without any changes to the parser.
* I don't see why {{RelDataTypeSystem.deriveModeType}} is necessary. The type 
is always the type of the expression, right?
* Add a comment to each test in agg.iq, with the intent of the test. E.g. one 
test seems to be deliberately testing by a NULL group key. Another is 
deliberately applying MODE to the group key.
* Is there a test of MODE applied to not-null column in an empty table (or 
WHERE FALSE); if not, add one.
* Add a test (maybe in {{agg.iq}}) for {{MODE}} with {{FILTER (WHERE ...)}}
* I see that you allow {{DISTINCT}}. {{DISTINCT}} makes {{MODE}} trivial, so I 
think you should omit ALL and DISTINCT from the syntax in reference.md. 
(PostgreSQL throws if you specify DISTINCT. I think we should allow it.) Also 
can you add a test case with DISTINCT, stating what is the expected behavior.
* Do you expect MODE to work as a windowed aggregate function? If so, add a 
test to winagg.iq. 
* Add a test case for MODE in a {{GROUPING SETS}} query.

> Add MODE aggregate function
> ---------------------------
>
>                 Key: CALCITE-4661
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4661
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: duan xiong
>            Assignee: duan xiong
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> Add MODE functions in the operator table which returns the most frequent 
> input value (arbitrarily choosing the first one if there are multiple 
> equally-frequent results)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to