Support views with explicit column names

A `CREATE VIEW` statement may provide names for its columns that
override the names of the columns derived from the view's query.
This commit is contained in:
Nikhil Benesch 2019-05-30 17:06:06 -04:00
parent 2f4cd8f6c8
commit 73ed685879
No known key found for this signature in database
GPG key ID: F7386C5DEADABA7F
3 changed files with 37 additions and 3 deletions

View file

@ -775,7 +775,7 @@ impl Parser {
// Many dialects support `OR REPLACE` | `OR ALTER` right after `CREATE`, but we don't (yet).
// ANSI SQL and Postgres support RECURSIVE here, but we don't support it either.
let name = self.parse_object_name()?;
// Parenthesized "output" columns list could be handled here.
let columns = self.parse_parenthesized_column_list(Optional)?;
let with_options = if self.parse_keyword("WITH") {
self.parse_with_options()?
} else {
@ -786,6 +786,7 @@ impl Parser {
// Optional `WITH [ CASCADED | LOCAL ] CHECK OPTION` is widely supported here.
Ok(SQLStatement::SQLCreateView {
name,
columns,
query,
materialized,
with_options,