Repository: sqlfluff/sqlfluff
Pull request: Grammar: Adds support for ALTER VIEW statement for Postgres dialect
### Brief summary of the change made
Adds support for parsing `ALTER VIEW` statements for the Postgres dialect
Closes #2094 

### Are there any other side effects of this change that we should be aware of?
None

### Pull Request checklist
- [x] Please confirm you have completed any of the necessary steps below.

- Included test cases to demonstrate any code changes, which may be one or more of the following:
  - `.yml` rule test cases in `test/fixtures/rules/std_rule_cases`.
  - `.sql`/`.yml` parser test cases in `test/fixtures/dialects` (note YML files can be auto generated with `python test/generate_parse_fixture_yml.py` or by running `tox` locally).
  - Full autofix test cases in `test/fixtures/linter/autofix`.
  - Other.
- Added appropriate documentation for the change.
- Created GitHub issues for any relevant followup/future enhancements if appropriate.


Problem statement:
Postgres: Add support for ALTER VIEW statement
## Expected Behaviour
SQLFluff should be able to parse `ALTER VIEW` statements

## Observed Behaviour
```shell
sqlfluff lint --dialect postgres -n sample.sql

== [sample.sql] FAIL                                                                                                                                                                                                                  
L:   1 | P:   1 |  PRS | Line 1, Position 1: Found unparsable section: 'ALTER
                       | VIEW myview ALTER date_column SET ...'
```

## Steps to Reproduce
1. Create `sample.sql` using the following query
```sql
ALTER VIEW myview ALTER date_column SET DEFAULT NOW();
```
2. sqlfluff lint --dialect postgres -n sample.sql
3. sqlfluff parse --dialect postgres -n sample.sql

## Dialect
`postgres`

## Version
`sqlfluff, version 0.8.2 and master`
`Python 3.8.22`

## Configuration
```
N/A : Default configuration
```

Hints from issue discussion:

Commit message: Merge branch 'main' into 2094-postgres-alter-view

Patch to review:
diff --git a/src/sqlfluff/dialects/dialect_postgres.py b/src/sqlfluff/dialects/dialect_postgres.py
index 47961e83795..b8fa950c317 100644
--- a/src/sqlfluff/dialects/dialect_postgres.py
+++ b/src/sqlfluff/dialects/dialect_postgres.py
@@ -1647,6 +1647,83 @@ class DropMaterializedViewStatementSegment(BaseSegment):
     )
 
 
+@postgres_dialect.segment()
+class AlterViewStatementSegment(BaseSegment):
+    """A `ALTER VIEW` statement.
+
+    As specified in https://www.postgresql.org/docs/14/sql-alterview.html
+    """
+
+    type = "alter_view_statement"
+
+    match_grammar = StartsWith(Sequence("ALTER", "VIEW"))
+
+    parse_grammar = Sequence(
+        "ALTER",
+        "VIEW",
+        Ref("IfExistsGrammar", optional=True),
+        Ref("TableReferenceSegment"),
+        OneOf(
+            Sequence(
+                "ALTER",
+                Ref.keyword("COLUMN", optional=True),
+                Ref("ColumnReferenceSegment"),
+                OneOf(
+                    Sequence(
+                        "SET",
+                        "DEFAULT",
+                        OneOf(
+                            Ref("LiteralGrammar"),
+                            Ref("FunctionSegment"),
+                            Ref("BareFunctionSegment"),
+                            Ref("ExpressionSegment"),
+                        ),
+                    ),
+                    Sequence("DROP", "DEFAULT"),
+                ),
+            ),
+            Sequence(
+                "OWNER",
+                "TO",
+                OneOf(
+                    Ref("ObjectReferenceSegment"),
+                    "CURRENT_ROLE",
+                    "CURRENT_USER",
+                    "SESSION_USER",
+                ),
+            ),
+            Sequence(
+                "RENAME",
+                Ref.keyword("COLUMN", optional=True),
+                Ref("ColumnReferenceSegment"),
+                "TO",
+                Ref("ColumnReferenceSegment"),
+            ),
+            Sequence("RENAME", "TO", Ref("TableReferenceSegment")),
+            Sequence("SET", "SCHEMA", Ref("SchemaReferenceSegment")),
+            Sequence(
+                "SET",
+                Bracketed(
+                    Delimited(
+                        Sequence(
+                            Ref("ParameterNameSegment"),
+                            Sequence(
+                                Ref("EqualsSegment"),
+                                Ref("LiteralGrammar"),
+                                optional=True,
+                            ),
+                        )
+                    )
+                ),
+            ),
+            Sequence(
+                "RESET",
+                Bracketed(Delimited(Ref("ParameterNameSegment"))),
+            ),
+        ),
+    )
+
+
 @postgres_dialect.segment(replace=True)
 class CreateDatabaseStatementSegment(BaseSegment):
     """A `CREATE DATABASE` statement.
@@ -2669,6 +2746,7 @@ class StatementSegment(BaseSegment):
             Ref("AlterDatabaseStatementSegment"),
             Ref("DropDatabaseStatementSegment"),
             Ref("AlterFunctionStatementSegment"),
+            Ref("AlterViewStatementSegment"),
         ],
     )
 
diff --git a/test/fixtures/dialects/postgres/postgres_alter_view.sql b/test/fixtures/dialects/postgres/postgres_alter_view.sql
new file mode 100644
index 00000000000..e18dc649c57
--- /dev/null
+++ b/test/fixtures/dialects/postgres/postgres_alter_view.sql
@@ -0,0 +1,53 @@
+-- issue:2094
+ALTER VIEW myview ALTER date_column SET DEFAULT NOW();
+ALTER VIEW myview ALTER int_column SET DEFAULT 1;
+ALTER VIEW myview ALTER text_column SET DEFAULT 'value';
+ALTER VIEW myview ALTER bool_column SET DEFAULT false;
+ALTER VIEW myview ALTER other_column SET DEFAULT other_value;
+ALTER VIEW myview ALTER other_column SET DEFAULT CURRENT_TIMESTAMP;
+ALTER VIEW myview ALTER other_column SET DEFAULT a_function(a_parameter);
+ALTER VIEW myview ALTER other_column SET DEFAULT a_function('a_parameter');
+ALTER VIEW myview ALTER other_column DROP DEFAULT;
+ALTER VIEW IF EXISTS myview ALTER date_column SET DEFAULT NOW();
+ALTER VIEW IF EXISTS myview ALTER int_column SET DEFAULT 1;
+ALTER VIEW IF EXISTS myview ALTER text_column SET DEFAULT 'value';
+ALTER VIEW IF EXISTS myview ALTER bool_column SET DEFAULT false;
+ALTER VIEW IF EXISTS myview ALTER other_column SET DEFAULT other_value;
+ALTER VIEW IF EXISTS myview ALTER other_column SET DEFAULT CURRENT_TIMESTAMP;
+ALTER VIEW IF EXISTS myview ALTER other_column SET DEFAULT a_function(a_parameter);
+ALTER VIEW IF EXISTS myview ALTER other_column SET DEFAULT a_function('a_parameter');
+ALTER VIEW IF EXISTS myview ALTER other_column DROP DEFAULT;
+
+ALTER VIEW myview OWNER TO baz_role;
+ALTER VIEW myview OWNER TO "baz-role";
+ALTER VIEW myview OWNER TO CURRENT_ROLE;
+ALTER VIEW myview OWNER TO CURRENT_USER;
+ALTER VIEW myview OWNER TO SESSION_USER;
+ALTER VIEW IF EXISTS myview OWNER TO baz_role;
+ALTER VIEW IF EXISTS myview OWNER TO "baz-role";
+ALTER VIEW IF EXISTS myview OWNER TO CURRENT_ROLE;
+ALTER VIEW IF EXISTS myview OWNER TO CURRENT_USER;
+ALTER VIEW IF EXISTS myview OWNER TO SESSION_USER;
+
+ALTER VIEW myview RENAME column_name TO new_column_name;
+ALTER VIEW myview RENAME COLUMN column_name TO new_column_name;
+ALTER VIEW IF EXISTS myview RENAME column_name TO new_column_name;
+ALTER VIEW IF EXISTS myview RENAME COLUMN column_name TO new_column_name;
+
+ALTER VIEW myview RENAME TO new_name;
+ALTER VIEW IF EXISTS myview RENAME TO new_name;
+
+ALTER VIEW myview SET SCHEMA new_schema;
+ALTER VIEW IF EXISTS myview SET SCHEMA new_schema;
+
+ALTER VIEW myview SET ( view_option_name );
+ALTER VIEW myview SET ( view_option_name  = 1);
+ALTER VIEW myview SET ( view_option_name  = 1, view_option_name2 = 'value', view_option_name3, view_option_name4 = false);
+ALTER VIEW IF EXISTS myview SET ( view_option_name );
+ALTER VIEW IF EXISTS myview SET ( view_option_name  = 1);
+ALTER VIEW IF EXISTS myview SET ( view_option_name, view_option_name2 = 1, view_option_name3);
+
+ALTER VIEW myview RESET ( view_option_name );
+ALTER VIEW myview RESET ( view_option_name, view_option_name2 );
+ALTER VIEW IF EXISTS myview RESET ( view_option_name );
+ALTER VIEW IF EXISTS myview RESET ( view_option_name, view_option_name2 );
diff --git a/test/fixtures/dialects/postgres/postgres_alter_view.yml b/test/fixtures/dialects/postgres/postgres_alter_view.yml
new file mode 100644
index 00000000000..d72d7d2d5aa
--- /dev/null
+++ b/test/fixtures/dialects/postgres/postgres_alter_view.yml
@@ -0,0 +1,679 @@
+# YML test files are auto-generated from SQL files and should not be edited by
+# hand. To help enforce this, the "hash" field in the file must match a hash
+# computed by SQLFluff when running the tests. Please run
+# `python test/generate_parse_fixture_yml.py`  to generate them after adding or
+# altering SQL files.
+_hash: bad5f939248c55ff51b8532d988381141f68dc179967c6268d63925bd9136b76
+file:
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: date_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - function:
+        function_name:
+          function_name_identifier: NOW
+        bracketed:
+          start_bracket: (
+          end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: int_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - literal: '1'
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: text_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - literal: "'value'"
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: bool_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - literal: 'false'
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: other_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - expression:
+        column_reference:
+          identifier: other_value
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: other_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - bare_function: CURRENT_TIMESTAMP
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: other_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - function:
+        function_name:
+          function_name_identifier: a_function
+        bracketed:
+          start_bracket: (
+          expression:
+            column_reference:
+              identifier: a_parameter
+          end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: other_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - function:
+        function_name:
+          function_name_identifier: a_function
+        bracketed:
+          start_bracket: (
+          expression:
+            literal: "'a_parameter'"
+          end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: other_column
+    - keyword: DROP
+    - keyword: DEFAULT
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: date_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - function:
+        function_name:
+          function_name_identifier: NOW
+        bracketed:
+          start_bracket: (
+          end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: int_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - literal: '1'
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: text_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - literal: "'value'"
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: bool_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - literal: 'false'
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: other_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - expression:
+        column_reference:
+          identifier: other_value
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: other_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - bare_function: CURRENT_TIMESTAMP
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: other_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - function:
+        function_name:
+          function_name_identifier: a_function
+        bracketed:
+          start_bracket: (
+          expression:
+            column_reference:
+              identifier: a_parameter
+          end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: other_column
+    - keyword: SET
+    - keyword: DEFAULT
+    - function:
+        function_name:
+          function_name_identifier: a_function
+        bracketed:
+          start_bracket: (
+          expression:
+            literal: "'a_parameter'"
+          end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: ALTER
+    - column_reference:
+        identifier: other_column
+    - keyword: DROP
+    - keyword: DEFAULT
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: OWNER
+    - keyword: TO
+    - object_reference:
+        identifier: baz_role
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: OWNER
+    - keyword: TO
+    - object_reference:
+        identifier: '"baz-role"'
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: OWNER
+    - keyword: TO
+    - keyword: CURRENT_ROLE
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: OWNER
+    - keyword: TO
+    - object_reference:
+        identifier: CURRENT_USER
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: OWNER
+    - keyword: TO
+    - keyword: SESSION_USER
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: OWNER
+    - keyword: TO
+    - object_reference:
+        identifier: baz_role
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: OWNER
+    - keyword: TO
+    - object_reference:
+        identifier: '"baz-role"'
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: OWNER
+    - keyword: TO
+    - keyword: CURRENT_ROLE
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: OWNER
+    - keyword: TO
+    - object_reference:
+        identifier: CURRENT_USER
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: OWNER
+    - keyword: TO
+    - keyword: SESSION_USER
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: RENAME
+    - column_reference:
+        identifier: column_name
+    - keyword: TO
+    - column_reference:
+        identifier: new_column_name
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: RENAME
+    - keyword: COLUMN
+    - column_reference:
+        identifier: column_name
+    - keyword: TO
+    - column_reference:
+        identifier: new_column_name
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: RENAME
+    - column_reference:
+        identifier: column_name
+    - keyword: TO
+    - column_reference:
+        identifier: new_column_name
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: RENAME
+    - keyword: COLUMN
+    - column_reference:
+        identifier: column_name
+    - keyword: TO
+    - column_reference:
+        identifier: new_column_name
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: RENAME
+    - keyword: TO
+    - table_reference:
+        identifier: new_name
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: RENAME
+    - keyword: TO
+    - table_reference:
+        identifier: new_name
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: SET
+    - keyword: SCHEMA
+    - schema_reference:
+        identifier: new_schema
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: SET
+    - keyword: SCHEMA
+    - schema_reference:
+        identifier: new_schema
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: SET
+    - bracketed:
+        start_bracket: (
+        parameter: view_option_name
+        end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: SET
+    - bracketed:
+        start_bracket: (
+        parameter: view_option_name
+        comparison_operator: '='
+        literal: '1'
+        end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: SET
+    - bracketed:
+      - start_bracket: (
+      - parameter: view_option_name
+      - comparison_operator: '='
+      - literal: '1'
+      - comma: ','
+      - parameter: view_option_name2
+      - comparison_operator: '='
+      - literal: "'value'"
+      - comma: ','
+      - parameter: view_option_name3
+      - comma: ','
+      - parameter: view_option_name4
+      - comparison_operator: '='
+      - literal: 'false'
+      - end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: SET
+    - bracketed:
+        start_bracket: (
+        parameter: view_option_name
+        end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: SET
+    - bracketed:
+        start_bracket: (
+        parameter: view_option_name
+        comparison_operator: '='
+        literal: '1'
+        end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: SET
+    - bracketed:
+      - start_bracket: (
+      - parameter: view_option_name
+      - comma: ','
+      - parameter: view_option_name2
+      - comparison_operator: '='
+      - literal: '1'
+      - comma: ','
+      - parameter: view_option_name3
+      - end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: RESET
+    - bracketed:
+        start_bracket: (
+        parameter: view_option_name
+        end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - table_reference:
+        identifier: myview
+    - keyword: RESET
+    - bracketed:
+      - start_bracket: (
+      - parameter: view_option_name
+      - comma: ','
+      - parameter: view_option_name2
+      - end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: RESET
+    - bracketed:
+        start_bracket: (
+        parameter: view_option_name
+        end_bracket: )
+- statement_terminator: ;
+- statement:
+    alter_view_statement:
+    - keyword: ALTER
+    - keyword: VIEW
+    - keyword: IF
+    - keyword: EXISTS
+    - table_reference:
+        identifier: myview
+    - keyword: RESET
+    - bracketed:
+      - start_bracket: (
+      - parameter: view_option_name
+      - comma: ','
+      - parameter: view_option_name2
+      - end_bracket: )
+- statement_terminator: ;


Code review comments:
diff_hunk: @@ -1647,6 +1647,83 @@ class DropMaterializedViewStatementSegment(BaseSegment):
     )
 
 
+@postgres_dialect.segment()
+class AlterViewStatementSegment(BaseSegment):
+    """A `ALTER VIEW` statement.
path: src/sqlfluff/dialects/dialect_postgres.py
text: @user1:
```suggestion
    """An `ALTER VIEW` statement.
```