You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Shant Hovsepian (Jira)" <ji...@apache.org> on 2020/07/18 22:12:00 UTC

[jira] [Created] (IMPALA-9973) Perform distinct elimination with constraint information

Shant Hovsepian created IMPALA-9973:
---------------------------------------

             Summary: Perform distinct elimination with constraint information
                 Key: IMPALA-9973
                 URL: https://issues.apache.org/jira/browse/IMPALA-9973
             Project: IMPALA
          Issue Type: Sub-task
          Components: Frontend
            Reporter: Shant Hovsepian


Table constraints (primary key, unique key) or reference integrity constraint information can be used to remove unnecessary DISTINCT aggregation.

T1 (A, B, C)

T2 (X, Y, Z)

Given the constraints:

primary key (T1.A)

primary key (T2.X, T2.Y)

T1 foreign key references T2

T1.B -> T2.X

T1.C -> T2.Y

 

Distinct can be removed:

SELECT DISTINCT T1.A, T1.B FROM T1;

SELECT DISTINCT T2.X, T2.Y FROM T2;

SELECT DISTINCT T1.A, T2.X, T2.Y, T2.Z FROM T1 INNER JOIN T2 ON (T1.B=T2.X and T1.C = T2.Y)

 

Distinct can't be removed:

SELECT DISTINCT T2.X, T2.Z FROM T2;

SELECT DISTINCT T1.A, T2.X, T2.Z FROM T1 INNER JOIN T2 ON (T1.B=T2.X and T1.C = T2.Y)

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org