Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 5, 2022

Conversation

yuval-illumex
Copy link
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
Copy link
Contributor

@alamb alamb left a comment

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
Copy link
Contributor

alamb commented Feb 5, 2022

🤔 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