Skip to content

Support parentheses in DISTINCT clause, CURRENT_TIMESTAMP, CURRENT_TIME, and CURRENT_DATE#391

Merged
alamb merged 8 commits into
mainfrom
unknown repository
Feb 5, 2022
Merged

Support parentheses in DISTINCT clause, CURRENT_TIMESTAMP, CURRENT_TIME, and CURRENT_DATE#391
alamb merged 8 commits into
mainfrom
unknown repository

Conversation

@yuval-illumex

Copy link
Copy Markdown
Contributor

The following query works in TrinoDB:

SELECT DISTINCT (orderstatus,orderpriority)
FROM tpch.sf1.orders 
LIMIT 10

@alamb alamb changed the title Allow parentheses in distinct Support parentheses in DISTINCT clause, CURRENT_TIMESTAMP, CURRENT_TIME, and CURRENT_DATE Feb 5, 2022

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yuval-illumex -- Sorry for the delay in review

@alamb alamb merged commit fbc1d96 into apache:main Feb 5, 2022
@alamb alamb mentioned this pull request Feb 5, 2022
@alamb

alamb commented Feb 5, 2022

Copy link
Copy Markdown
Contributor

🤔 I didn't catch this prior to merge, but there appears to be a difference between (col1, col2) and col1, col2 in postgres

alamb=# select distinct (t1_id, t1_name) from t1;
  row   
--------
 (11,a)
 (22,b)
 (33,c)
 (44,d)
 (77,e)
(5 rows)

alamb=# select distinct t1_id, t1_name from t1;
 t1_id | t1_name 
-------+---------
    44 | d
    77 | e
    11 | a
    22 | b
    33 | c
(5 rows)

alamb=# 

Turns out mysql doesn't like this syntax at all:

mysql> select distinct t1_id, t1_name from t1;
+-------+---------+
| t1_id | t1_name |
+-------+---------+
|    11 | a       |
|    22 | b       |
|    33 | c       |
|    44 | d       |
|    77 | e       |
+-------+---------+
5 rows in set (0.01 sec)

mysql> select distinct (t1_id, t1_name) from t1;
ERROR 1241 (21000): Operand should contain 1 column(s)
mysql> 

@yuval-illumex any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants