GoogleCloudPlatform / bigquery-antipattern-recognition

Utility to identify and rewrite common anti patterns in BigQuery SQL syntax
Apache License 2.0
82 stars 28 forks source link

Added : Anti-Pattern for reducing data before joins #34

Closed PoulamiR1994 closed 3 weeks ago

franklinWhaite commented 12 months ago

Please consider de following case, the current implementation is not detecting the antipattern if it happens within a subquery

SELECT
    tt1.sum_col2, count(1) ct
FROM 
    (SELECT 
        t1.col1, sum(t2.col2) sum_col2
    FROM 
        t1
    JOIN
        t2 ON t1.col1 = t2.col2
    GROUP BY
        t1.col1 ) tt1
GROUP BY    
    tt1.sum_col2