You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "liyang (JIRA)" <ji...@apache.org> on 2015/11/16 03:50:10 UTC

[jira] [Commented] (CALCITE-969) Order by (A, B) and order by (A) treats NULL differently

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

liyang commented on CALCITE-969:
--------------------------------

Copy solution discussion from email.

Julian Hyde <jh...@apache.org>
Nov 14


For extra credit, the fix would allow the position of nulls to be configurable. In CalciteConnectionProperty, add

  enum NullCollation { LOW, HIGH, FIRST, LAST }

and

  DEFAULT_NULL_COLLATION, default HIGH (last for ASC, first for DESC).

The minimum fix is to support HIGH without looking at a config property.

> Order by (A, B) and order by (A) treats NULL differently
> --------------------------------------------------------
>
>                 Key: CALCITE-969
>                 URL: https://issues.apache.org/jira/browse/CALCITE-969
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: liyang
>            Assignee: Julian Hyde
>
> NULL first or NULL last is not clearly defined by sql spec, but should be consistent in calcite.
> I spot order by (A desc) returns NULL last, but order by (A desc, B) returns NULL first.
> E.g.  "select cal_dt, country, ... from xxx order by COUNTRY DESC"  returns
> 2013-08-11	US  ....
> 2013-08-18	FR  ....
> 2013-03-31	null	....
> 2013-11-10	null	....
> E.g.  "select cal_dt, country, ... from xxx order by COUNTRY DESC, CAL_DT ASC"  returns
> 2013-03-31	null	....
> 2013-11-10	null	....
> 2013-08-11	US  ....
> 2013-08-18	FR  ....



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)