• Nisha Gopalakrishnan's avatar
    BUG#19886430: VIEW CREATION WITH NAMED COLUMNS, OVER UNION, · b5380e09
    Nisha Gopalakrishnan authored
                  IS REJECTED.
    
    Analysis
    ========
    
    View creation with named columns over UNION is rejected.
    Consider the following view definition:
    
    CREATE VIEW v1 (fld1, fld2) AS SELECT 1 AS a, 2 AS b
    UNION ALL SELECT 1 AS a, 1 AS a;
    
    A 'duplicate column' error was reported due to the duplicate
    alias name in the secondary SELECT. The VIEW column names
    are either explicitly specified or determined from the
    first SELECT (which can be auto generated if not specified).
    Since a duplicate column name check was performed even
    for the secondary SELECTs, an error was reported.
    
    Fix
    ====
    
    Check for duplicate column names only for the named
    columns if specified or only for the first SELECT.
    b5380e09
sql_view.cc 62.5 KB