2

Original query:

SELECT CAST(cust_mart.acct_identifier AS STRING) as f0 
FROM   cts_work.cust_xref cust_mart 
GROUP BY cust_mart.f0;      

Can I replace the above query with below query :

 SELECT DISTINCT CAST(cust_mart.acct_identifier AS STRING) as f0 
 FROM cts_work.cust_xref cust_mart;

Reason: there is no aggregation so group-by does not make sense, but still confirming my approach I am running this query on hive using TEZ engine

Vidya K
  • 103
  • 8

1 Answers1

0

Use EXPLAIN command and compare two query plans to check the difference. These queries should generate identical plans. Group by will work the same as distinct in this case. DISTINCT is also an aggregation, just another word for the same group by.

leftjoin
  • 36,950
  • 8
  • 57
  • 116