Implementation of DISTINCT and ORDER BY

2020-08-03 Thread Hrudaya Reddy
Hi all, I am trying to generate the following SQL query but I am facing some difficulties in finding the right syntax to implement 'DISTINCT' and 'ORDER BY' SELECT DISTINCT name_first, name_last FROM users ORDER BY name_last DESC I would really appreciate it if you could guide me with the corr

Re: Implementation of DISTINCT and ORDER BY

2020-08-03 Thread Rui Wang
I did a test locally and I found your example syntax is correct. I used "select distinct deptno, empno from emp order by empno desc" and Calcite generates this plan: LogicalSort(sort0=[$1], dir0=[DESC]) LogicalAggregate(group=[{0, 1}]) LogicalProject(DEPTNO=[$7], EMPNO=[$0]) LogicalTa

RE: Re: Implementation of DISTINCT and ORDER BY

2020-08-04 Thread Hrudaya Reddy
t] IS NULL THEN 0 ELSE 1 END, [name_last] DESC So, just wanted to make sure that this is the right approach. Regards, Hrudaya -Original Message- From: Rui Wang Sent: Monday, August 3, 2020 10:08 PM To: dev@calcite.apache.org Subject: [EXTERNAL] Re: Implementation of DISTINCT and ORDER B

Re: Re: Implementation of DISTINCT and ORDER BY

2020-08-04 Thread Rui Wang
[name_last] DESC > > So, just wanted to make sure that this is the right approach. > > Regards, > Hrudaya > > -Original Message- > From: Rui Wang > Sent: Monday, August 3, 2020 10:08 PM > To: dev@calcite.apache.org > Subject: [EXTERNAL] Re: Implementation of DISTI

Re: Re: Implementation of DISTINCT and ORDER BY

2020-08-06 Thread Julian Hyde
e_last] > > ORDER BY CASE WHEN [name_last] IS NULL THEN 0 ELSE 1 END, [name_last] DESC > > > > So, just wanted to make sure that this is the right approach. > > > > Regards, > > Hrudaya > > > > -Original Message- > > From: Rui Wang &g

RE: Re: Re: Implementation of DISTINCT and ORDER BY

2020-08-06 Thread Hrudaya Reddy
Thanks for your input Julian and Rui. Regards, Hrudaya -Original Message- From: Julian Hyde Sent: Thursday, August 6, 2020 10:03 AM To: dev@calcite.apache.org Subject: [EXTERNAL] Re: Re: Implementation of DISTINCT and ORDER BY The CASE is to make null values collate first or last. I