uber / queryparser

Parsing and analysis of Vertica, Hive, and Presto SQL.
MIT License
1.08k stars 147 forks source link

fix Vertica "CREATE VIEW" statement parsing #49

Closed lukas-mi closed 5 years ago

lukas-mi commented 5 years ago

Vertica CREATE VIEW statements can contain more complex SELECT queries (including UNION, ORDER BY and other clauses). Since all of the currently existing value constructors of Query are supported by Vertica in SELECT and therefore in CREATE VIEW, queryP can be used in parsing CREATE VIEW statements.

Related issue - #48

CLAassistant commented 5 years ago

CLA assistant check
All committers have signed the CLA.

lukas-mi commented 5 years ago

I'm not really familiar with the code base but this seemed like an obvious solution. Also regarding tests I guess testing this would be redundant since there are already tests covering various SELECT cases.

h4v0kh3l1 commented 5 years ago

Yeah, this fix looks good. If you could add the one failing parse case of

CREATE VIEW test_schema.test_view_union AS
    SELECT
        a0 as a,
        b0 as b
    FROM test_schema.test_table_0
UNION
    SELECT
        a1 as a,
        b1 as b
    FROM test_schema.test_table_1;

to https://github.com/uber/queryparser/blob/master/test/Database/Sql/Vertica/Parser/Test.hs, that would address all my concerns

lukas-mi commented 5 years ago

updated